Restored PHPStan 2.2.6 compatibility in PublicMethodReflection - #28
Merged
Conversation
PHPStan 2.2.6 added getPureUnlessCallableIsImpureParameters() to ExtendedMethodReflection, so PublicMethodReflection no longer satisfies the interface and every analysis run fatals when the class is loaded: Class Maho\PHPStanPlugin\Reflection\PublicMethodReflection contains 1 abstract method and must therefore be declared abstract or implement the remaining method Delegate the new method to the wrapped reflection and raise the phpstan requirement to ^2.2.6, the first release that declares it.
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.
PHPStan 2.2.6 added
getPureUnlessCallableIsImpureParameters()toExtendedMethodReflection.PublicMethodReflectiondoesn't implement it, so as soon as the class is autoloaded every analysis run dies:It's triggered through
BindThisScopeResolverExtension, i.e. any phtml template or install script that calls a protected method on$this.Changes
PublicMethodReflection::getPureUnlessCallableIsImpureParameters()delegating to the wrapped reflection, like every other member of the wrapper.phpstan/phpstanrequirement raised^2.1→^2.2.6. 2.2.5 is the last release without the method, and analysing this repo against it fails with "call to an undefined method" plus areturn.typeerror on the new delegation, so^2.2isn't enough.Verification
vendor/bin/phpstan analyseis clean on this branch, and a full run of the maho monorepo (5261 files, PHPStan 2.2.6) no longer fatals.