Skip to content
Merged
Show file tree
Hide file tree
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
10 changes: 10 additions & 0 deletions build/build-preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ final class PreloadBuilder
declare(strict_types=1);

use PhpParser\Node;
use PhpParser\NodeTraverser;
use PHPStan\Testing\PHPStanTestCase;

if (defined('__PHPSTAN_RUNNING__')) {
Expand Down Expand Up @@ -230,6 +231,15 @@ private function createRequireOnceFilePathLine(string $realPath): string
}

$filePath = '/vendor/' . Strings::after($realPath, 'vendor/');

// PHPStan Turbo declares its native NodeTraverser before this file runs
if ($filePath === '/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php') {
return 'if (! class_exists(NodeTraverser::class, false)) {' . PHP_EOL
. " require_once __DIR__ . '" . $filePath . "';" . PHP_EOL
. '}' . PHP_EOL
. PHP_EOL;
}

return "require_once __DIR__ . '" . $filePath . "';" . PHP_EOL;
}

Expand Down
6 changes: 5 additions & 1 deletion preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
declare(strict_types=1);

use PhpParser\Node;
use PhpParser\NodeTraverser;
use PHPStan\Testing\PHPStanTestCase;

if (defined('__PHPSTAN_RUNNING__')) {
Expand Down Expand Up @@ -274,7 +275,10 @@ function isPHPStanTestPreloaded(): bool
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/Node/VariadicPlaceholder.php';
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeDumper.php';
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeFinder.php';
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php';
if (! class_exists(NodeTraverser::class, false)) {
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeTraverser.php';
}

require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CloningVisitor.php';
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/CommentAnnotatingVisitor.php';
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeVisitor/FindingVisitor.php';
Expand Down
Loading