|
17 | 17 | use Amp\Parallel\Worker\TaskFailureThrowable; |
18 | 18 | use ArrayIterator; |
19 | 19 | use BadMethodCallException; |
| 20 | +use Closure; |
20 | 21 | use Countable; |
21 | 22 | use DateTimeImmutable; |
22 | 23 | use Fidry\FileSystem\FS; |
@@ -127,7 +128,7 @@ public function endBuffering(?callable $dumpAutoload): void |
127 | 128 | { |
128 | 129 | Assert::true($this->buffering, 'The buffering must be started before ending it'); |
129 | 130 |
|
130 | | - $dumpAutoload ??= static fn () => null; |
| 131 | + $completeDumpAutoload = self::createDumpAutoload($dumpAutoload); |
131 | 132 | $cwd = getcwd(); |
132 | 133 |
|
133 | 134 | $tmp = FS::makeTmpDir('box', self::class); |
@@ -156,11 +157,7 @@ public function endBuffering(?callable $dumpAutoload): void |
156 | 157 | ); |
157 | 158 | } |
158 | 159 |
|
159 | | - $dumpAutoload( |
160 | | - $this->scoper->getSymbolsRegistry(), |
161 | | - $this->scoper->getPrefix(), |
162 | | - $this->scoper->getExcludedFilePaths(), |
163 | | - ); |
| 160 | + $completeDumpAutoload(); |
164 | 161 |
|
165 | 162 | $unknownFiles = fromPairs( |
166 | 163 | map( |
@@ -191,6 +188,22 @@ public function endBuffering(?callable $dumpAutoload): void |
191 | 188 | $this->phar->stopBuffering(); |
192 | 189 | } |
193 | 190 |
|
| 191 | + /** |
| 192 | + * @param null|(callable(SymbolsRegistry, string, string[]): void) $dumpAutoload |
| 193 | + * |
| 194 | + * @return Closure():void |
| 195 | + */ |
| 196 | + private function createDumpAutoload(?callable $dumpAutoload): Closure |
| 197 | + { |
| 198 | + return null === $dumpAutoload |
| 199 | + ? static fn () => null |
| 200 | + : fn () => $dumpAutoload( |
| 201 | + $this->scoper->getSymbolsRegistry(), |
| 202 | + $this->scoper->getPrefix(), |
| 203 | + $this->scoper->getExcludedFilePaths(), |
| 204 | + ); |
| 205 | + } |
| 206 | + |
194 | 207 | /** |
195 | 208 | * @param non-empty-string $normalizedVendorDir Normalized path ("/" path separator and no trailing "/") to the Composer vendor directory |
196 | 209 | */ |
|
0 commit comments