Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parameter $object of method expects T of object, T of object|T of object given. #5893

Closed
VincentLanglet opened this issue Nov 1, 2021 · 7 comments

Comments

@VincentLanglet
Copy link
Contributor

Bug report

I'm starting using the 1.0 version and I have a weird issue.

Parameter #1 $object of static method Test::getClass() expects T of object, T of object|T of object given.

Code snippet that reproduces the problem

https://phpstan.org/r/bf359dd0-d44c-4b4d-9916-75e450c344fa

Removing the

if (method_exists($object, '__toString') && null !== $object->__toString()) {
    return $object->__toString();
}

fix the issue.

Expected output

No error

Did PHPStan help you today? Did it make you happy in any way?

Great job for the 1.0

@VincentLanglet
Copy link
Contributor Author

Friendly ping @ondrejmirtes, any idea where should I look at in the phpstan-src code for this bug ?

@ondrejmirtes
Copy link
Member

@VincentLanglet The type in else and after the condition is probably wrong: https://phpstan.org/r/4aa995ef-3e9e-470d-818c-f9954c262e71

Which means this is about what happens in MutatingScope::filterByFalseyValue().

@VincentLanglet
Copy link
Contributor Author

I have difficulties to debug this, but I discovered that
https://phpstan.org/r/db53ce31-4f9b-4cc6-9b66-16a6ee97bc0f
with method_exists($object, '__toString') && true is not working, but
https://phpstan.org/r/34f86f0e-9fd5-4723-af9d-21ae54e7fa84
with true && method_exists($object, '__toString') is working.

Dunno if it helps

@VincentLanglet
Copy link
Contributor Author

VincentLanglet commented Jan 31, 2022

Seems like this was solved in 1.4.4

@VincentLanglet
Copy link
Contributor Author

@ondrejmirtes Do you know if it was expected to be solved by a recent PR ?
Does this require a non-regression test or it already has similar one ?

@ondrejmirtes
Copy link
Member

Yes, I'll add a regression test.

@github-actions
Copy link

github-actions bot commented Mar 5, 2022

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants