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
8 changes: 2 additions & 6 deletions build/target-repository/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,15 @@
* 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')

// 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';
}
Expand Down
1 change: 0 additions & 1 deletion scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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+
Expand Down
9 changes: 1 addition & 8 deletions src/Testing/PHPUnit/AbstractLazyTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Rector\Testing\PHPUnit;

use PHPUnit\Framework\TestCase;
use PHPUnit\Runner\Version;
use Rector\Config\RectorConfig;
use Rector\DependencyInjection\LazyContainerFactory;

Expand Down Expand Up @@ -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';
Expand Down