Repository navigation
Conversation
PHPStan indexes the directories in paths for static reflection, but only looks at *.php files by default. A class in a processed *.inc file was not known by name, and since 2.8.0 fetchClassLikeReflection() throws "Class ... should be known at this point" for it.
samsonasik
reviewed
Nov 6, 2026
|
|
||
| return RectorConfig::configure() | ||
| ->withPaths([__DIR__ . '/src']) | ||
| ->withFileExtensions(['php', 'inc']) |
Member
There was a problem hiding this comment.
this should be differentiate between file extension scanned by rector and phpstan I guess, since scanned by rector means it will fixable via rector.
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 rectorphp/rector#9958
With
withFileExtensions(['php', 'inc'])the*.incfiles in a directory path are processed, but PHPStan indexes that directory for static reflection with its ownfileExtensions, which is onlyphp. The classes in those files are not known by name, so since 2.8.0fetchClassLikeReflection()throwsClass "App\ChildService" should be known at this point. TheClassLikepassed to it is the node being traversed (ChildServicehere,BaseProviderin the trace from the issue), so the class is unknown only because PHPStan never scanned the file that declares it. 2.7 did not crash, but a parent declared in another*.incfile was not found either, soAddParamBasedOnParentClassMethodRectorchanged nothing there.The PHPStan container now gets the extensions from
withFileExtensions(). The new e2e test fails on main with the error above, and on the LAM repository from the issue the error is gone for all 116.incfiles that hit it.