Skip to content

Commit 603b8bd

Browse files
committed
handling on phpunit 12.+ only
1 parent 7c2760f commit 603b8bd

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

build/target-repository/bootstrap.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?php
22

3-
declare(strict_types = 1);
3+
declare(strict_types=1);
44

55
use PHPParser\Node;
6+
use PHPUnit\Runner\Version;
67

78
/**
89
* The preload.php contains 2 dependencies
@@ -18,6 +19,10 @@
1819

1920
// no need to preload if Node interface exists
2021
&& ! interface_exists(Node::class, false)
22+
23+
// ensure force autoload version with class_exists() with true argument as not yet loaded
24+
// for phpunit 12+ only
25+
&& class_exists(Version::class, true) && (int) Version::id() >= 12
2126
) {
2227
require_once __DIR__ . '/preload.php';
2328
}
@@ -32,7 +37,7 @@
3237
}
3338

3439
// load prefixed or native class, e.g. for running tests
35-
if (strpos($class, 'RectorPrefix') === 0 || strpos($class, 'Rector\\') === 0) {
40+
if (str_starts_with($class, 'RectorPrefix') || str_starts_with($class, 'Rector\\')) {
3641
if ($composerAutoloader === null) {
3742
// prefixed version autoload
3843
$composerAutoloader = require __DIR__ . '/vendor/autoload.php';

0 commit comments

Comments
 (0)