diff --git a/build/target-repository/bootstrap.php b/build/target-repository/bootstrap.php index e8ee6428d0a..d993b89afe0 100644 --- a/build/target-repository/bootstrap.php +++ b/build/target-repository/bootstrap.php @@ -13,7 +13,6 @@ * They need to be loaded early to avoid conflict version between rector prefixed vendor and Project vendor * For example, a project may use phpstan/phpdoc-parser v1, while rector uses phpstan/phpdoc-parser uses v2, that will error as class or logic are different. */ -$isGlobalPHPUnit = class_exists(Version::class, false); if ( // verify PHPUnit is running defined('PHPUNIT_COMPOSER_INSTALL') @@ -21,11 +20,8 @@ // no need to preload if Node interface exists && ! interface_exists(Node::class, false) - && ! $isGlobalPHPUnit - - // ensure force autoload version with class_exists() with true argument as not yet loaded - // for phpunit 12+ only - && class_exists(Version::class, true) && (int) Version::id() >= 12 + // load preload.php on local PHPUnit installation + && ! class_exists(Version::class, false) ) { require_once __DIR__ . '/preload.php'; } diff --git a/scoper.php b/scoper.php index e8893e4b34f..73d00ecf873 100644 --- a/scoper.php +++ b/scoper.php @@ -33,7 +33,6 @@ 'exclude-classes' => [ 'PHPUnit\Framework\Constraint\IsEqual', 'PHPUnit\Framework\TestCase', - 'PHPUnit\Runner\Version', 'PHPUnit\Framework\ExpectationFailedException', // native class on php 8.3+ diff --git a/src/Testing/PHPUnit/AbstractLazyTestCase.php b/src/Testing/PHPUnit/AbstractLazyTestCase.php index 3fc41dd2e3a..720990bc0ac 100644 --- a/src/Testing/PHPUnit/AbstractLazyTestCase.php +++ b/src/Testing/PHPUnit/AbstractLazyTestCase.php @@ -5,7 +5,6 @@ namespace Rector\Testing\PHPUnit; use PHPUnit\Framework\TestCase; -use PHPUnit\Runner\Version; use Rector\Config\RectorConfig; use Rector\DependencyInjection\LazyContainerFactory; @@ -64,13 +63,7 @@ private function includePreloadFilesAndScoperAutoload(): void { if (file_exists(__DIR__ . '/../../../preload.php')) { if (file_exists(__DIR__ . '/../../../vendor')) { - /** - * On PHPUnit 12+, when classmap autoloaded, it means preload already loaded early - */ - if (! class_exists(Version::class, true) || (int) Version::id() < 12) { - require_once __DIR__ . '/../../../preload.php'; - } - + require_once __DIR__ . '/../../../preload.php'; // test case in rector split package } elseif (file_exists(__DIR__ . '/../../../../../../vendor')) { require_once __DIR__ . '/../../../preload-split-package.php';