Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions src/Box.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Amp\Parallel\Worker\TaskFailureThrowable;
use ArrayIterator;
use BadMethodCallException;
use Closure;
use Countable;
use DateTimeImmutable;
use Fidry\FileSystem\FS;
Expand Down Expand Up @@ -123,7 +124,7 @@ public function endBuffering(?callable $dumpAutoload): void
{
Assert::true($this->buffering, 'The buffering must be started before ending it');

$dumpAutoload ??= static fn () => null;
$completeDumpAutoload = self::createDumpAutoload($dumpAutoload);
$cwd = getcwd();

$tmp = FS::makeTmpDir('box', self::class);
Expand All @@ -150,11 +151,7 @@ public function endBuffering(?callable $dumpAutoload): void
);
}

$dumpAutoload(
$this->scoper->getSymbolsRegistry(),
$this->scoper->getPrefix(),
$this->scoper->getExcludedFilePaths(),
);
$completeDumpAutoload();

$unknownFiles = Finder::create()
->files()
Expand Down Expand Up @@ -182,6 +179,22 @@ public function endBuffering(?callable $dumpAutoload): void
$this->phar->stopBuffering();
}

/**
* @param null|(callable(SymbolsRegistry, string, string[]): void) $dumpAutoload
*
* @return Closure():void
*/
private function createDumpAutoload(?callable $dumpAutoload): Closure
{
return null === $dumpAutoload
? static fn () => null
: fn () => $dumpAutoload(
$this->scoper->getSymbolsRegistry(),
$this->scoper->getPrefix(),
$this->scoper->getExcludedFilePaths(),
);
}

/**
* @param non-empty-string $normalizedVendorDir Normalized path ("/" path separator and no trailing "/") to the Composer vendor directory
*/
Expand Down
Loading