Skip to content

Commit 7c2760f

Browse files
committed
ensure verify Node interface exists
1 parent 6acc4e6 commit 7c2760f

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

build/target-repository/bootstrap.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
declare(strict_types = 1);
44

5+
use PHPParser\Node;
6+
57
/**
68
* The preload.php contains 2 dependencies
79
* - phpstan/phpdoc-parser
@@ -10,7 +12,13 @@
1012
* They need to be loaded early to avoid conflict version between rector prefixed vendor and Project vendor
1113
* For example, a project may use PHPParser v4, while Rector uses v5, that will error as class or logic are different.
1214
*/
13-
if (defined('PHPUNIT_COMPOSER_INSTALL')) {
15+
if (
16+
// verify PHPUnit is running
17+
defined('PHPUNIT_COMPOSER_INSTALL')
18+
19+
// no need to preload if Node interface exists
20+
&& ! interface_exists(Node::class, false)
21+
) {
1422
require_once __DIR__ . '/preload.php';
1523
}
1624

0 commit comments

Comments
 (0)