-
-
Notifications
You must be signed in to change notification settings - Fork 417
[autoload] Add workaround for phpstan + rector tests co-run to avoid duplicated php-parser loading error #7440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2,11 +2,28 @@ | |||||||||||||||||||
|
|
||||||||||||||||||||
| declare(strict_types=1); | ||||||||||||||||||||
|
|
||||||||||||||||||||
| use PhpParser\Node; | ||||||||||||||||||||
| use PHPStan\Testing\PHPStanTestCase; | ||||||||||||||||||||
|
Comment on lines
+5
to
+6
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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: rector-src/.github/workflows/weekly_pull_requests.yaml Lines 21 to 29 in 89bfc23
or on |
||||||||||||||||||||
|
|
||||||||||||||||||||
| if (defined('__PHPSTAN_RUNNING__')) { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/Node.php'; | ||||||||||||||||||||
| // 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') && isPHPStanTestPreloaded()) { | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| function isPHPStanTestPreloaded(): bool | ||||||||||||||||||||
| { | ||||||||||||||||||||
| if (! class_exists(PHPStanTestCase::class, false)) { | ||||||||||||||||||||
| return false; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| return interface_exists(Node::class, false); | ||||||||||||||||||||
| }require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/Node.php'; | ||||||||||||||||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. new line is needed here.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||
| require_once __DIR__ . '/src/Contract/PhpParser/Node/StmtsAwareInterface.php'; | ||||||||||||||||||||
| require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/NodeAbstract.php'; | ||||||||||||||||||||
| require_once __DIR__ . '/../../../vendor/nikic/php-parser/lib/PhpParser/Node/Expr.php'; | ||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also
preload-split-package.php: