Skip to content

Commit

Permalink
[Autoloading] Proper fix for fix bootstrap phpunit.phar (#5522)
Browse files Browse the repository at this point in the history
  • Loading branch information
samsonasik authored Jan 30, 2024
1 parent 3c51cd8 commit f680a07
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/Autoloading/BootstrapFilesIncluder.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public function includeBootstrapFiles(): void

Assert::allString($bootstrapFiles);

$isLoadPHPUnitPhar = false;

/** @var string[] $bootstrapFiles */
foreach ($bootstrapFiles as $bootstrapFile) {
if (! is_file($bootstrapFile)) {
Expand All @@ -38,16 +40,21 @@ public function includeBootstrapFiles(): void
// load phar file
if (str_ends_with($bootstrapFile, '.phar')) {
Phar::loadPhar($bootstrapFile);

if (str_ends_with($bootstrapFile, 'phpunit.phar')) {
$isLoadPHPUnitPhar = true;
}

continue;
}

require $bootstrapFile;
}

$this->requireRectorStubs();
$this->requireRectorStubs($isLoadPHPUnitPhar);
}

private function requireRectorStubs(): void
private function requireRectorStubs(bool $isLoadPHPUnitPhar): void
{
/** @var false|string $stubsRectorDirectory */
$stubsRectorDirectory = realpath(__DIR__ . '/../../stubs-rector');
Expand All @@ -63,7 +70,13 @@ private function requireRectorStubs(): void
$stubs = new RecursiveIteratorIterator($dir);

foreach ($stubs as $stub) {
require_once $stub->getRealPath();
$realPath = $stub->getRealPath();

if ($isLoadPHPUnitPhar && str_ends_with($realPath, 'TestCase.php')) {
continue;
}

require_once $realPath;
}
}
}

0 comments on commit f680a07

Please sign in to comment.