Skip to content
Closed
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
2 changes: 2 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,8 @@ parameters:
# for config class reflection
- src/Bootstrap/ExtensionConfigResolver.php
- src/Validation/RectorConfigValidator.php
# for phpunit version check
- src/Testing/PHPUnit/AbstractLazyTestCase.php

# use of internal phpstan classes
-
Expand Down
1 change: 1 addition & 0 deletions scoper.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
'exclude-classes' => [
'PHPUnit\Framework\Constraint\IsEqual',
'PHPUnit\Framework\TestCase',
'PHPUnit\Runner\Version',
'PHPUnit\Framework\ExpectationFailedException',

// native class on php 8.3+
Expand Down
7 changes: 6 additions & 1 deletion src/Testing/PHPUnit/AbstractLazyTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Rector\Testing\PHPUnit;

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

Expand Down Expand Up @@ -63,7 +64,11 @@ private function includePreloadFilesAndScoperAutoload(): void
{
if (file_exists(__DIR__ . '/../../../preload.php')) {
if (file_exists(__DIR__ . '/../../../vendor')) {
require_once __DIR__ . '/../../../preload.php';
// this ensure to not load preload.php on phpunit >= 12
if (! class_exists(Version::class) || (int) Version::id() < 12) {
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