From 3468bc1d4c2a1bd869e8b4b7a7794d4252e5c89d Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 11 Oct 2025 06:13:04 +0700 Subject: [PATCH 1/2] [Alternative] Use direct check to avoid redeclare function isPHPStanTestPreloaded() --- preload.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/preload.php b/preload.php index cecb0b90b4c..55beb85fb92 100644 --- a/preload.php +++ b/preload.php @@ -12,19 +12,12 @@ // 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()) { +if (defined('PHPUNIT_COMPOSER_INSTALL') + && class_exists(PHPStanTestCase::class, false) + && interface_exists(Node::class, false)) { 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'; From fdb94bad8a86e15185a7f9badcf56192c3f27526 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 11 Oct 2025 06:14:17 +0700 Subject: [PATCH 2/2] [Alternative] Use direct check to avoid redeclare function isPHPStanTestPreloaded() --- build/build-preload.php | 13 +++---------- preload-split-package.php | 13 +++---------- 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/build/build-preload.php b/build/build-preload.php index de87adabbbc..9f460325fd3 100755 --- a/build/build-preload.php +++ b/build/build-preload.php @@ -61,18 +61,11 @@ final class PreloadBuilder // 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()) { +if (defined('PHPUNIT_COMPOSER_INSTALL') + && class_exists(PHPStanTestCase::class, false) + && interface_exists(Node::class, false)) { 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..6a969d4aad8 100644 --- a/preload-split-package.php +++ b/preload-split-package.php @@ -12,19 +12,12 @@ // 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()) { +if (defined('PHPUNIT_COMPOSER_INSTALL') + && class_exists(PHPStanTestCase::class, false) + && interface_exists(Node::class, false)) { 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';