You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
2.3.0 regression: internal error with first-class method callable and closure in a generic array argument #15432
After upgrading to PHPStan 2.3.0, analysis crashes with PHPStan\ShouldNotHappenException: Internal error. when a generic array argument contains both a first-class instance method callable and an anonymous function.
The exception originates in InitializerExprTypeResolver.php:743, with getFirstClassCallableType() and gatherArrayArgTypeSkeleton() in the stack trace.
I reproduced this without Laravel, Larastan, or other extensions, using PHP 8.5.11 at analysis level 8. The same code passes analysis with PHPStan 2.2.17 and executes successfully in PHP.
Assigning the method callable to a variable before placing it in the array avoids the crash in PHPStan 2.3.0.
PHPStan should complete analysis without errors, as PHPStan 2.2.17 does for the same snippet. Both callbacks satisfy the declared parameter type, and the code executes successfully in PHP.
PHPStan 2.3.0 should produce the same result whether the method callable is placed directly in the array or assigned to a variable first. Neither form should cause an internal error.
Did PHPStan help you today? Did it make you happy in any way?
PHPStan regularly catches issues before they reach production and gives me more confidence when refactoring. Thanks for all the work you put into it!
Thanks for the reproducer. Fixed in phpstan/phpstan-src#6701. The regression covers direct and nested method callables alongside closures, and checks that incompatible callbacks still produce the expected error. The full PHP and Turbo suites pass locally; upstream CI is running.
Activity
drewmt commentedon Oct 8, 2026
Thanks for the reproducer. Fixed in phpstan/phpstan-src#6701. The regression covers direct and nested method callables alongside closures, and checks that incompatible callbacks still produce the expected error. The full PHP and Turbo suites pass locally; upstream CI is running.