|
13 | 13 | use function array_filter;
|
14 | 14 | use function array_map;
|
15 | 15 | use function array_merge;
|
| 16 | +use function array_unique; |
16 | 17 | use function array_values;
|
17 | 18 | use function glob;
|
18 | 19 | use function is_dir;
|
19 | 20 | use function is_string;
|
20 | 21 | use function realpath;
|
| 22 | +use function sort; |
| 23 | +use function stripos; |
| 24 | +use function substr; |
21 | 25 | use AppendIterator;
|
22 | 26 | use FilesystemIterator;
|
23 | 27 | use RecursiveDirectoryIterator;
|
@@ -106,39 +110,45 @@ private function resolveWildcards(array $paths): array
|
106 | 110 |
|
107 | 111 | /**
|
108 | 112 | * @see https://gist.github.com/funkjedi/3feee27d873ae2297b8e2370a7082aad
|
109 |
| - * @param string $pattern |
110 |
| - * @return list<non-empty-string> |
| 113 | + * |
| 114 | + * @return list<string> |
111 | 115 | */
|
112 |
| - private function globstar(string $pattern) { |
| 116 | + private function globstar(string $pattern) |
| 117 | + { |
113 | 118 | if (stripos($pattern, '**') === false) {
|
114 | 119 | $files = glob($pattern, GLOB_ONLYDIR);
|
115 | 120 | } else {
|
116 |
| - $position = stripos($pattern, '**'); |
| 121 | + $position = stripos($pattern, '**'); |
117 | 122 | $rootPattern = substr($pattern, 0, $position - 1);
|
118 | 123 | $restPattern = substr($pattern, $position + 2);
|
119 | 124 |
|
120 |
| - $patterns = [$rootPattern.$restPattern]; |
| 125 | + $patterns = [$rootPattern . $restPattern]; |
121 | 126 | $rootPattern .= '/*';
|
122 | 127 |
|
123 |
| - while($dirs = glob($rootPattern, GLOB_ONLYDIR)) { |
| 128 | + while ($dirs = glob($rootPattern, GLOB_ONLYDIR)) { |
124 | 129 | $rootPattern .= '/*';
|
125 |
| - foreach($dirs as $dir) { |
| 130 | + |
| 131 | + foreach ($dirs as $dir) { |
126 | 132 | $patterns[] = $dir . $restPattern;
|
127 | 133 | }
|
128 | 134 | }
|
129 | 135 |
|
130 | 136 | $files = [];
|
131 |
| - foreach($patterns as $pat) { |
| 137 | + |
| 138 | + foreach ($patterns as $pat) { |
132 | 139 | $files = array_merge($files, $this->globstar($pat));
|
133 | 140 | }
|
134 | 141 | }
|
135 | 142 |
|
136 |
| - if($files !== false) { |
| 143 | + if ($files !== false) { |
137 | 144 | $files = array_unique($files);
|
138 | 145 | sort($files);
|
| 146 | + |
139 | 147 | return $files;
|
140 | 148 | }
|
141 | 149 |
|
| 150 | + // @codeCoverageIgnoreStart |
142 | 151 | return [];
|
| 152 | + // @codeCoverageIgnoreEnd |
143 | 153 | }
|
144 | 154 | }
|
0 commit comments