Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes phpstan/phpstan#15475
FileTypeMappercaches name scopes by file contents, but its parser currently depends on which paths are being analysed. When a file is only scanned for symbols,CleaningParserremoves function bodies, including classes declared inside them. The incomplete name-scope map survives later full analyses because the file has not changed. In the reported example, the anonymous class constructor loses itsClosure(string): list<string>PHPDoc, andsearch()is incorrectly reported as returningmixed.Use a separate parser route for
FileTypeMapperthat always retains the full AST. It shares the existing cached rich parser and preserves the PHP 8 parser route for version-independent stub files. Normal analysis/reflection routing and the explicit stub-file mapper remain unchanged. Bump the name-scope cache format to v8 so existing incomplete entries are rebuilt rather than reused.The E2E regression checks a cold full analysis, then a partial analysis followed by a full analysis with the same PHPDoc cache. It fails before the fix with
return.typeand passes afterward. The workflow runs it on PHP 8.3 and with Turbo enabled.Validation on the current
2.3.xbase (62ed20078):FileTypeMapperTest: 6 tests / 90 assertions.To reproduce the regression test: