Skip to content

Restored PHPStan 2.2.6 compatibility in PublicMethodReflection - #28

Merged
fballiano merged 1 commit into
mainfrom
fix/phpstan-2.2.6-compatibility
Jul 27, 2026
Merged

Restored PHPStan 2.2.6 compatibility in PublicMethodReflection#28
fballiano merged 1 commit into
mainfrom
fix/phpstan-2.2.6-compatibility

Conversation

@fballiano

Copy link
Copy Markdown
Contributor

PHPStan 2.2.6 added getPureUnlessCallableIsImpureParameters() to ExtendedMethodReflection. PublicMethodReflection doesn't implement it, so as soon as the class is autoloaded every analysis run dies:

Child process error (exit code 255): PHP Fatal error: Class Maho\PHPStanPlugin\Reflection\PublicMethodReflection
contains 1 abstract method and must therefore be declared abstract or implement the remaining method
(PHPStan\Reflection\ExtendedMethodReflection::getPureUnlessCallableIsImpureParameters)

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/phpstan requirement 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 a return.type error on the new delegation, so ^2.2 isn't enough.

Verification

vendor/bin/phpstan analyse is clean on this branch, and a full run of the maho monorepo (5261 files, PHPStan 2.2.6) no longer fatals.

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.
@fballiano
fballiano merged commit f46b2ee into main Jul 27, 2026
6 checks passed
@fballiano
fballiano deleted the fix/phpstan-2.2.6-compatibility branch July 27, 2026 08:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant