Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions build/build-preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ final class PreloadBuilder
return;
}

// edge case during Rector tests case, happens when
// 1. phpstan autoload test case is triggered first,
// 2. all php-parser classes are loaded,
if (defined('PHPUNIT_COMPOSER_INSTALL') && class_exists(\PHPStan\Testing\PHPStanTestCase::class, false) && interface_exists(\PhpParser\Node::class, false)) {
return;
}

CODE_SAMPLE;

Expand Down
13 changes: 13 additions & 0 deletions preload-split-package.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

declare(strict_types=1);

use PhpParser\Node;
use PHPStan\Testing\PHPStanTestCase;
Comment on lines +5 to +6
Copy link
Member

@samsonasik samsonasik Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this may cause repetitive apply cs after rebuild weekly, if cs is required, the cs fix position needs to be after generate preload on workflow build so it always have same result:

-
name: 'Apply Coding Standard'
run: "composer fix-cs"
branch: 'automated-apply-coding-standards'
-
name: 'Re-Generate preload.php'
run: "composer preload"
branch: 'automated-regenerated-preload'

or on build/build-preload.php script, or add use statement early there.


if (defined('__PHPSTAN_RUNNING__')) {
return;
}

// edge case during Rector tests case, happens when
// 1. phpstan autoload test case is triggered first,
// 2. all php-parser classes are loaded,
if (defined('PHPUNIT_COMPOSER_INSTALL') && class_exists(
PHPStanTestCase::class,
false
) && interface_exists(Node::class, false)) {
return;
}

require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/Node.php';
require_once __DIR__ . '/src/Contract/PhpParser/Node/StmtsAwareInterface.php';
require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php';
Expand Down
13 changes: 13 additions & 0 deletions preload.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,23 @@

declare(strict_types=1);

use PhpParser\Node;
use PHPStan\Testing\PHPStanTestCase;

if (defined('__PHPSTAN_RUNNING__')) {
return;
}

// edge case during Rector tests case, happens when
// 1. phpstan autoload test case is triggered first,
// 2. all php-parser classes are loaded,
if (defined('PHPUNIT_COMPOSER_INSTALL') && class_exists(
PHPStanTestCase::class,
false
) && interface_exists(Node::class, false)) {
return;
}

require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/Node.php';
require_once __DIR__ . '/src/Contract/PhpParser/Node/StmtsAwareInterface.php';
require_once __DIR__ . '/vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
use PhpParser\Node\FunctionLike;
use PhpParser\Node\Param;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\ClassMethod;
use PHPStan\PhpDocParser\Ast\ConstExpr\ConstFetchNode;
use PHPStan\PhpDocParser\Ast\Node;
use PHPStan\PhpDocParser\Ast\PhpDoc\ParamTagValueNode;
Expand Down