[Reflection] Add ClassReflectionProvider facade over PHPStan ReflectionProvider - #8216
Open
TomasVotruba wants to merge 1 commit into
Open
[Reflection] Add ClassReflectionProvider facade over PHPStan ReflectionProvider#8216TomasVotruba wants to merge 1 commit into
TomasVotruba wants to merge 1 commit into
Conversation
…onProvider Route class lookups through a narrow Rector-owned facade, so rules and services no longer depend on PHPStan\Reflection\ReflectionProvider directly. Files importing ReflectionProvider drop from 68 to 16; the remaining ones are engine internals that also need function/constant/anonymous-class lookups. 10 files lose their last phpstan/phpstan import entirely.
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.
First step of lowering direct
phpstan/phpstancoupling, while keeping all rules running on PHPStan's reflection underneath.What
Class lookups now go through a narrow Rector-owned facade instead of
PHPStan\Reflection\ReflectionProvider:Call sites change mechanically:
Some files lose their last PHPStan import outright:
Why
ReflectionProviderwas imported in 68 files, but only 6 of its methods were ever called — and 55 files used nothing buthasClass()/getClass(). That is a wide import surface over a very narrow API.Routing it through one class means a future change to how Rector resolves class reflection has a single edit point instead of 68.
Numbers
ReflectionProviderrules/files importing anyPHPStan\phpstan/phpstanimportsThe 16 remaining are engine internals (
PHPStanNodeScopeResolver,NodeTypeResolver,AstResolver,ReflectionResolver, the DI factories) plus rules doing function/constant lookups — those needhasFunction()/getFunction()/hasConstant()/getAnonymousClassReflection(), deliberately left out of this facade. A function-lookup equivalent can follow separately.No behaviour change: the facade delegates straight to the same
ReflectionProviderinstance, resolved by autowiring from the existingPUBLIC_PHPSTAN_SERVICE_TYPESregistration.