File tree Expand file tree Collapse file tree 5 files changed +56
-3
lines changed
src/BetterPhpDocParser/PhpDocManipulator Expand file tree Collapse file tree 5 files changed +56
-3
lines changed Original file line number Diff line number Diff line change @@ -51,11 +51,28 @@ final class PreloadBuilder
5151
5252declare(strict_types=1);
5353
54+ use PhpParser\Node;
55+ use PHPStan\Testing\PHPStanTestCase;
56+
5457if (defined('__PHPSTAN_RUNNING__')) {
5558 return;
5659}
5760
61+ // edge case during Rector tests case, happens when
62+ // 1. phpstan autoload test case is triggered first,
63+ // 2. all php-parser classes are loaded,
64+ if (defined('PHPUNIT_COMPOSER_INSTALL') && isPHPStanTestPreloaded()) {
65+ return;
66+ }
5867
68+ function isPHPStanTestPreloaded(): bool
69+ {
70+ if (! class_exists(PHPStanTestCase::class, false)) {
71+ return false;
72+ }
73+
74+ return interface_exists(Node::class, false);
75+ }
5976CODE_SAMPLE;
6077
6178 /**
Original file line number Diff line number Diff line change 2424 '*/Fixture/* ' ,
2525 '*/Expected/* ' ,
2626
27+ // avoid re-running on build
28+ __DIR__ . '/preload.php ' ,
29+
2730 PhpdocTypesFixer::class => [
2831 // double to Double false positive
2932 __DIR__ . '/rules/Php74/Rector/Double/RealToFloatTypeCastRector.php ' ,
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5+ use PhpParser \Node ;
6+ use PHPStan \Testing \PHPStanTestCase ;
7+
58if (defined ('__PHPSTAN_RUNNING__ ' )) {
69 return ;
710}
811
9- require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/Node.php ' ;
12+ // edge case during Rector tests case, happens when
13+ // 1. phpstan autoload test case is triggered first,
14+ // 2. all php-parser classes are loaded,
15+ if (defined ('PHPUNIT_COMPOSER_INSTALL ' ) && isPHPStanTestPreloaded ()) {
16+ return ;
17+ }
18+
19+ function isPHPStanTestPreloaded (): bool
20+ {
21+ if (! class_exists (PHPStanTestCase::class, false )) {
22+ return false ;
23+ }
24+
25+ return interface_exists (Node::class, false );
26+ }require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/Node.php ' ;
1027require_once __DIR__ . '/src/Contract/PhpParser/Node/StmtsAwareInterface.php ' ;
1128require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php ' ;
1229require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php ' ;
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5+ use PhpParser \Node ;
6+ use PHPStan \Testing \PHPStanTestCase ;
7+
58if (defined ('__PHPSTAN_RUNNING__ ' )) {
69 return ;
710}
811
9- require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/Node.php ' ;
12+ // edge case during Rector tests case, happens when
13+ // 1. phpstan autoload test case is triggered first,
14+ // 2. all php-parser classes are loaded,
15+ if (defined ('PHPUNIT_COMPOSER_INSTALL ' ) && isPHPStanTestPreloaded ()) {
16+ return ;
17+ }
18+
19+ function isPHPStanTestPreloaded (): bool
20+ {
21+ if (! class_exists (PHPStanTestCase::class, false )) {
22+ return false ;
23+ }
24+
25+ return interface_exists (Node::class, false );
26+ }require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/Node.php ' ;
1027require_once __DIR__ . '/src/Contract/PhpParser/Node/StmtsAwareInterface.php ' ;
1128require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php ' ;
1229require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php ' ;
Original file line number Diff line number Diff line change 77use PhpParser \Node \FunctionLike ;
88use PhpParser \Node \Param ;
99use PhpParser \Node \Stmt ;
10- use PhpParser \Node \Stmt \ClassMethod ;
1110use PHPStan \PhpDocParser \Ast \ConstExpr \ConstFetchNode ;
1211use PHPStan \PhpDocParser \Ast \Node ;
1312use PHPStan \PhpDocParser \Ast \PhpDoc \ParamTagValueNode ;
You can’t perform that action at this time.
0 commit comments