|
35 | 35 | use RecursiveDirectoryIterator; |
36 | 36 | use RuntimeException; |
37 | 37 | use Seld\PharUtils\Timestamps; |
38 | | -use SplFileInfo; |
39 | 38 | use Symfony\Component\Finder\Finder; |
| 39 | +use Symfony\Component\Finder\SplFileInfo; |
40 | 40 | use Webmozart\Assert\Assert; |
41 | 41 | use function array_map; |
42 | 42 | use function array_unshift; |
|
46 | 46 | use function file_exists; |
47 | 47 | use function getcwd; |
48 | 48 | use function is_object; |
| 49 | +use function iter\fromPairs; |
| 50 | +use function iter\map; |
49 | 51 | use function openssl_pkey_export; |
50 | 52 | use function openssl_pkey_get_details; |
51 | 53 | use function openssl_pkey_get_private; |
52 | 54 | use function sprintf; |
| 55 | +use function strcmp; |
53 | 56 | use function strval; |
| 57 | +use function uksort; |
54 | 58 |
|
55 | 59 | /** |
56 | 60 | * Box is a utility class to generate a PHAR. |
@@ -156,19 +160,22 @@ public function endBuffering(?callable $dumpAutoload): void |
156 | 160 | $this->scoper->getExcludedFilePaths(), |
157 | 161 | ); |
158 | 162 |
|
159 | | - $unknownFiles = Finder::create() |
160 | | - ->files() |
161 | | - ->in($tmp) |
162 | | - ->notPath(array_keys($files)); |
| 163 | + $unknownFiles = fromPairs( |
| 164 | + map( |
| 165 | + static fn (SplFileInfo $fileInfo) => [ |
| 166 | + $fileInfo->getRelativePathname(), |
| 167 | + $fileInfo->getPathname(), |
| 168 | + ], |
| 169 | + Finder::create() |
| 170 | + ->files() |
| 171 | + ->in($tmp) |
| 172 | + ->notPath(array_keys($files)), |
| 173 | + ), |
| 174 | + ); |
163 | 175 |
|
164 | 176 | $files = [...$files, ...$unknownFiles]; |
165 | 177 |
|
166 | | - uasort($files, static function (SplFileInfo|string $a, SplFileInfo|string $b) { |
167 | | - $a = is_string($a) ? $a : $a->getPath(); |
168 | | - $b = is_string($b) ? $b : $b->getPath(); |
169 | | - |
170 | | - return strcmp($a, $b); |
171 | | - }); |
| 178 | + uksort($files, strcmp(...)); |
172 | 179 |
|
173 | 180 | $this->phar->buildFromIterator(new ArrayIterator($files), $tmp); |
174 | 181 | } finally { |
|
0 commit comments