Repository navigation
Conversation
|
CI note: the The PHP 7.4 call syntax and Turbo version-pin failures from my first push have been corrected in the current head. |
4e6c817 to
1abd49e
Compare
1abd49e to
dd7bc45
Compare
dd7bc45 to
083179b
Compare
|
//cc @SanderMuller |
|
the issue phpstan/phpstan#15482 talks about unexpected rule errors. we should have a test which asserts these unexpected rule errors no longer appear |
|
I ran the reporter's three files from phpstan/phpstan#15482 as a project. 2.3.x reports Two shapes still lose the constant on this branch: function foo(): string
{
return bar(class: 'x');
}
const BAR = 'bar';and if ($typeLevel <= 0) {
$typeLevel = 0;
$inType = false;
}With that change on top of this branch, all 8 shapes I tried find About a test for the rule errors: a What I checked:
|
|
Thanks for checking this. I added an E2E case using the reporter's three-file layout and covered the named class argument and spaced class constant variants in the scanner fixture. Both the PHP and native scanners now reset the type state when its depth reaches zero. The E2E analysis and targeted symbol-finder tests pass locally. The update is in 5988ead. |
When a global constant follows
stdClass::classinside a function, the directory symbol scan can mistake theclassname token for a declaration and lose the constant. The same can happen with identifiers beginning withclass. This change checks the keyword boundary before entering type scope in both the PHP cleaner and the Turbo scanner.The regression covers
::class,className(), and a real anonymous class. The native differential corpora also include the trigger. Thanks to @Victor-emil for identifying the cause and suggesting the boundary check in phpstan/phpstan#15482.Validation: the focused PHPUnit test passes (3 tests); the source-locator suite passes (78 tests, 159 assertions, 1 skip); and the issue's two-file example analyzes without errors using this branch. PHP syntax and
git diff --checkpass. I could not run the native differential scripts locally because the Turbo extension is not installed.Fixes phpstan/phpstan#15482