Skip to content

Commit d10337a

Browse files
authored
[autoload] Remove PHPUnit version 12 check on preload.php load (#7474)
1 parent 0715911 commit d10337a

File tree

3 files changed

+3
-15
lines changed

3 files changed

+3
-15
lines changed

build/target-repository/bootstrap.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,19 +13,15 @@
1313
* They need to be loaded early to avoid conflict version between rector prefixed vendor and Project vendor
1414
* 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.
1515
*/
16-
$isGlobalPHPUnit = class_exists(Version::class, false);
1716
if (
1817
// verify PHPUnit is running
1918
defined('PHPUNIT_COMPOSER_INSTALL')
2019

2120
// no need to preload if Node interface exists
2221
&& ! interface_exists(Node::class, false)
2322

24-
&& ! $isGlobalPHPUnit
25-
26-
// ensure force autoload version with class_exists() with true argument as not yet loaded
27-
// for phpunit 12+ only
28-
&& class_exists(Version::class, true) && (int) Version::id() >= 12
23+
// load preload.php on local PHPUnit installation
24+
&& ! class_exists(Version::class, false)
2925
) {
3026
require_once __DIR__ . '/preload.php';
3127
}

scoper.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
'exclude-classes' => [
3434
'PHPUnit\Framework\Constraint\IsEqual',
3535
'PHPUnit\Framework\TestCase',
36-
'PHPUnit\Runner\Version',
3736
'PHPUnit\Framework\ExpectationFailedException',
3837

3938
// native class on php 8.3+

src/Testing/PHPUnit/AbstractLazyTestCase.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
namespace Rector\Testing\PHPUnit;
66

77
use PHPUnit\Framework\TestCase;
8-
use PHPUnit\Runner\Version;
98
use Rector\Config\RectorConfig;
109
use Rector\DependencyInjection\LazyContainerFactory;
1110

@@ -64,13 +63,7 @@ private function includePreloadFilesAndScoperAutoload(): void
6463
{
6564
if (file_exists(__DIR__ . '/../../../preload.php')) {
6665
if (file_exists(__DIR__ . '/../../../vendor')) {
67-
/**
68-
* On PHPUnit 12+, when classmap autoloaded, it means preload already loaded early
69-
*/
70-
if (! class_exists(Version::class, true) || (int) Version::id() < 12) {
71-
require_once __DIR__ . '/../../../preload.php';
72-
}
73-
66+
require_once __DIR__ . '/../../../preload.php';
7467
// test case in rector split package
7568
} elseif (file_exists(__DIR__ . '/../../../../../../vendor')) {
7669
require_once __DIR__ . '/../../../preload-split-package.php';

0 commit comments

Comments
 (0)