File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed
Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change 1515namespace KevinGH \Box ;
1616
1717use Amp \Parallel \Worker \TaskFailureThrowable ;
18+ use ArrayIterator ;
1819use BadMethodCallException ;
1920use Countable ;
2021use DateTimeImmutable ;
3536use RuntimeException ;
3637use Seld \PharUtils \Timestamps ;
3738use SplFileInfo ;
39+ use Symfony \Component \Finder \Finder ;
3840use Webmozart \Assert \Assert ;
3941use function array_map ;
4042use function array_unshift ;
@@ -137,7 +139,11 @@ public function endBuffering(?callable $dumpAutoload): void
137139 }
138140
139141 try {
142+ $ files = [];
143+
140144 foreach ($ this ->bufferedFiles as $ file ) {
145+ $ files [$ file ->getPath ()] = $ tmp .DIRECTORY_SEPARATOR .$ file ->getPath ();
146+
141147 FS ::dumpFile (
142148 $ file ->getPath (),
143149 $ file ->getContents (),
@@ -154,7 +160,22 @@ public function endBuffering(?callable $dumpAutoload): void
154160
155161 chdir ($ cwd );
156162
157- $ this ->phar ->buildFromDirectory ($ tmp );
163+ $ unknownFiles = Finder::create ()
164+ ->files ()
165+ ->in ($ tmp )
166+ ->notPath (array_keys ($ files ))
167+ ->sortByName ();
168+
169+ $ files = [...$ files , ...$ unknownFiles ];
170+
171+ uasort ($ files , static function (SplFileInfo |string $ a , SplFileInfo |string $ b ) {
172+ $ a = is_string ($ a ) ? $ a : $ a ->getPath ();
173+ $ b = is_string ($ b ) ? $ b : $ b ->getPath ();
174+
175+ return strcmp ($ a , $ b );
176+ });
177+
178+ $ this ->phar ->buildFromIterator (new ArrayIterator ($ files ), $ tmp );
158179 } finally {
159180 FS ::remove ($ tmp );
160181 }
You can’t perform that action at this time.
0 commit comments