-
Notifications
You must be signed in to change notification settings - Fork 112
Specify types for Doctrine Collection first() method #153
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
Specify types for Doctrine Collection first() method #153
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also add an integration test about this scenario.
You can see here how these things are tested: https://github.com/phpstan/phpstan-doctrine/tree/master/tests/DoctrineIntegration/ORM
|
|
||
| return $this->typeSpecifier->create( | ||
| new MethodCall($node->var, self::FIRST_METHOD_NAME), | ||
| TypeCombinator::remove(ParametersAcceptorSelector::selectSingle($methodVariants)->getReturnType(), new BooleanType()), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we're executing this now for all contexts, there should be an if-else about $context->truthy() and $context->falsey(). In the former case, isFirst is going to return false, in the second case, the false should be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have added a condition, but it doesn't have any effect for some reason. The errors "Cannot call method on" still remain.
|
Hi, I'm sorry, you'll have to debug it yourself, I can't dive into this right now. |
b2b2414 to
1fe21ab
Compare
|
Can be closed as #172 is merged. |
An attempt to solve #152.
PHPStan gives me a new error
Call to method Doctrine\Common\Collections\Collection<int,App\Entity\MyEntity>::isEmpty() will always evaluate to false., andCannot call method onerrors are still there.