Skip to content

Commit e476fb3

Browse files
committed
remove cs from preload
1 parent d1f3cf3 commit e476fb3

4 files changed

Lines changed: 33 additions & 11 deletions

File tree

build/build-preload.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,28 @@ final class PreloadBuilder
5151
5252
declare(strict_types=1);
5353
54+
use PhpParser\Node;
55+
use PHPStan\Testing\PHPStanTestCase;
56+
5457
if (defined('__PHPSTAN_RUNNING__')) {
5558
return;
5659
}
5760
5861
// edge case during Rector tests case, happens when
5962
// 1. phpstan autoload test case is triggered first,
6063
// 2. all php-parser classes are loaded,
61-
if (defined('PHPUNIT_COMPOSER_INSTALL') && class_exists(\PHPStan\Testing\PHPStanTestCase::class, false) && interface_exists(\PhpParser\Node::class, false)) {
64+
if (defined('PHPUNIT_COMPOSER_INSTALL') && isPHPStanTestPreloaded()) {
6265
return;
6366
}
6467
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+
}
6576
CODE_SAMPLE;
6677

6778
/**

ecs.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
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',

preload-split-package.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@
1212
// edge case during Rector tests case, happens when
1313
// 1. phpstan autoload test case is triggered first,
1414
// 2. all php-parser classes are loaded,
15-
if (defined('PHPUNIT_COMPOSER_INSTALL') && class_exists(
16-
PHPStanTestCase::class,
17-
false
18-
) && interface_exists(Node::class, false)) {
15+
if (defined('PHPUNIT_COMPOSER_INSTALL') && isPHPStanTestPreloaded()) {
1916
return;
2017
}
2118

22-
require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/Node.php';
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';
2327
require_once __DIR__ . '/src/Contract/PhpParser/Node/StmtsAwareInterface.php';
2428
require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php';
2529
require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php';

preload.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,18 @@
1212
// edge case during Rector tests case, happens when
1313
// 1. phpstan autoload test case is triggered first,
1414
// 2. all php-parser classes are loaded,
15-
if (defined('PHPUNIT_COMPOSER_INSTALL') && class_exists(
16-
PHPStanTestCase::class,
17-
false
18-
) && interface_exists(Node::class, false)) {
15+
if (defined('PHPUNIT_COMPOSER_INSTALL') && isPHPStanTestPreloaded()) {
1916
return;
2017
}
2118

22-
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/Node.php';
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';
2327
require_once __DIR__ . '/src/Contract/PhpParser/Node/StmtsAwareInterface.php';
2428
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php';
2529
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php';

0 commit comments

Comments
 (0)