diff --git a/build/build-preload.php b/build/build-preload.php index de87adabbbc..99eac46ca48 100755 --- a/build/build-preload.php +++ b/build/build-preload.php @@ -58,21 +58,23 @@ final class PreloadBuilder return; } +if (! function_exists('isPHPStanTestPreloaded')) { + function isPHPStanTestPreloaded(): bool + { + if (! class_exists(PHPStanTestCase::class, false)) { + return false; + } + + return interface_exists(Node::class, false); + } +} + // edge case during Rector tests case, happens when // 1. phpstan autoload test case is triggered first, // 2. all php-parser classes are loaded, if (defined('PHPUNIT_COMPOSER_INSTALL') && isPHPStanTestPreloaded()) { return; } - -function isPHPStanTestPreloaded(): bool -{ - if (! class_exists(PHPStanTestCase::class, false)) { - return false; - } - - return interface_exists(Node::class, false); -} CODE_SAMPLE; /** diff --git a/preload-split-package.php b/preload-split-package.php index da953d5a7e5..6277792f51c 100644 --- a/preload-split-package.php +++ b/preload-split-package.php @@ -9,6 +9,17 @@ return; } +if (! function_exists('isPHPStanTestPreloaded')) { + function isPHPStanTestPreloaded(): bool + { + if (! class_exists(PHPStanTestCase::class, false)) { + return false; + } + + return interface_exists(Node::class, false); + } +} + // edge case during Rector tests case, happens when // 1. phpstan autoload test case is triggered first, // 2. all php-parser classes are loaded, @@ -16,15 +27,6 @@ return; } -function isPHPStanTestPreloaded(): bool -{ - if (! class_exists(PHPStanTestCase::class, false)) { - return false; - } - - return interface_exists(Node::class, false); -} - require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/Node.php'; require_once __DIR__ . '/src/Contract/PhpParser/Node/StmtsAwareInterface.php'; require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php'; diff --git a/preload.php b/preload.php index cecb0b90b4c..15a5592d77c 100644 --- a/preload.php +++ b/preload.php @@ -9,6 +9,17 @@ return; } +if (! function_exists('isPHPStanTestPreloaded')) { + function isPHPStanTestPreloaded(): bool + { + if (! class_exists(PHPStanTestCase::class, false)) { + return false; + } + + return interface_exists(Node::class, false); + } +} + // edge case during Rector tests case, happens when // 1. phpstan autoload test case is triggered first, // 2. all php-parser classes are loaded, @@ -16,15 +27,6 @@ return; } -function isPHPStanTestPreloaded(): bool -{ - if (! class_exists(PHPStanTestCase::class, false)) { - return false; - } - - return interface_exists(Node::class, false); -} - require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/Node.php'; require_once __DIR__ . '/src/Contract/PhpParser/Node/StmtsAwareInterface.php'; require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php';