Mercurial > hg > isophonics-drupal-site
comparison vendor/symfony/class-loader/ClassMapGenerator.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
29 * @param string $file The name of the class map file | 29 * @param string $file The name of the class map file |
30 */ | 30 */ |
31 public static function dump($dirs, $file) | 31 public static function dump($dirs, $file) |
32 { | 32 { |
33 $dirs = (array) $dirs; | 33 $dirs = (array) $dirs; |
34 $maps = array(); | 34 $maps = []; |
35 | 35 |
36 foreach ($dirs as $dir) { | 36 foreach ($dirs as $dir) { |
37 $maps = array_merge($maps, static::createMap($dir)); | 37 $maps = array_merge($maps, static::createMap($dir)); |
38 } | 38 } |
39 | 39 |
47 * | 47 * |
48 * @return array A class map array | 48 * @return array A class map array |
49 */ | 49 */ |
50 public static function createMap($dir) | 50 public static function createMap($dir) |
51 { | 51 { |
52 if (is_string($dir)) { | 52 if (\is_string($dir)) { |
53 $dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)); | 53 $dir = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($dir)); |
54 } | 54 } |
55 | 55 |
56 $map = array(); | 56 $map = []; |
57 | 57 |
58 foreach ($dir as $file) { | 58 foreach ($dir as $file) { |
59 if (!$file->isFile()) { | 59 if (!$file->isFile()) { |
60 continue; | 60 continue; |
61 } | 61 } |
91 private static function findClasses($path) | 91 private static function findClasses($path) |
92 { | 92 { |
93 $contents = file_get_contents($path); | 93 $contents = file_get_contents($path); |
94 $tokens = token_get_all($contents); | 94 $tokens = token_get_all($contents); |
95 | 95 |
96 $classes = array(); | 96 $classes = []; |
97 | 97 |
98 $namespace = ''; | 98 $namespace = ''; |
99 for ($i = 0; isset($tokens[$i]); ++$i) { | 99 for ($i = 0; isset($tokens[$i]); ++$i) { |
100 $token = $tokens[$i]; | 100 $token = $tokens[$i]; |
101 | 101 |
108 switch ($token[0]) { | 108 switch ($token[0]) { |
109 case T_NAMESPACE: | 109 case T_NAMESPACE: |
110 $namespace = ''; | 110 $namespace = ''; |
111 // If there is a namespace, extract it | 111 // If there is a namespace, extract it |
112 while (isset($tokens[++$i][1])) { | 112 while (isset($tokens[++$i][1])) { |
113 if (in_array($tokens[$i][0], array(T_STRING, T_NS_SEPARATOR))) { | 113 if (\in_array($tokens[$i][0], [T_STRING, T_NS_SEPARATOR])) { |
114 $namespace .= $tokens[$i][1]; | 114 $namespace .= $tokens[$i][1]; |
115 } | 115 } |
116 } | 116 } |
117 $namespace .= '\\'; | 117 $namespace .= '\\'; |
118 break; | 118 break; |
127 } | 127 } |
128 | 128 |
129 if (T_DOUBLE_COLON === $tokens[$j][0]) { | 129 if (T_DOUBLE_COLON === $tokens[$j][0]) { |
130 $isClassConstant = true; | 130 $isClassConstant = true; |
131 break; | 131 break; |
132 } elseif (!in_array($tokens[$j][0], array(T_WHITESPACE, T_DOC_COMMENT, T_COMMENT))) { | 132 } elseif (!\in_array($tokens[$j][0], [T_WHITESPACE, T_DOC_COMMENT, T_COMMENT])) { |
133 break; | 133 break; |
134 } | 134 } |
135 } | 135 } |
136 | 136 |
137 if ($isClassConstant) { | 137 if ($isClassConstant) { |