Skip to content

Commit 6acc4e6

Browse files
committed
[Scoped] Load early preload.php on scoped bootstrap.php on phpunit running
1 parent 9a95b6b commit 6acc4e6

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

build/target-repository/bootstrap.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
declare(strict_types = 1);
44

5+
/**
6+
* The preload.php contains 2 dependencies
7+
* - phpstan/phpdoc-parser
8+
* - nikic/php-parser
9+
*
10+
* They need to be loaded early to avoid conflict version between rector prefixed vendor and Project vendor
11+
* For example, a project may use PHPParser v4, while Rector uses v5, that will error as class or logic are different.
12+
*/
13+
if (defined('PHPUNIT_COMPOSER_INSTALL')) {
14+
require_once __DIR__ . '/preload.php';
15+
}
16+
517
// inspired by https://github.com/phpstan/phpstan/blob/master/bootstrap.php
618
spl_autoload_register(function (string $class): void {
719
static $composerAutoloader;

0 commit comments

Comments
 (0)