Repository navigation
fix: resolve class string method detection - #25
Merged
MrPunyapal merged 1 commit intoOct 30, 2026
Merged
Conversation
MrPunyapal
approved these changes
Oct 30, 2026
Member
|
Thanks |
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.
#24 fixed the internal error for custom expectations declared through a
MethodsClassReflectionExtension. The same crash still happens for any methodPest\Expectationdoesn't know about when the expectation value is a class-string. That includes custom expectations registered withexpect()->extend()intests/Pest.php, which PHPStan never executes:The method is unknown to the plugin, so
resolveExpectationMethodCall()treats it as a higher-order call on the value.StringType::hasMethod()returns "maybe" for class-strings (to allow static calls), so the->no()guard inresolveMethodReturnType()lets the lookup continue.getMethod()on aStringTypethen throwsShouldNotHappenExceptionrather thanMissingMethodFromReflectionException, so it isn't caught.This PR also returns
mixedwhen the value can't be an object (isObject()->no()), since a class-string has no instance methods to resolve. Nullable objects such asPost|nullandmixedvalues still resolve as before.resolvePropertyType()doesn't need the same change: every string type answershasProperty()with a definite "no", which the existing guard already handles.expect(Post::class)->foo()is added to the higher-order method call fixture. It fails with the internal error above without the fix, and with it reports the same undefined method error asexpect('string')->foo().composer test:lint,composer test:typesand the whole suite pass.