Skip to content

Conversation

@fluffycondor
Copy link
Contributor

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., and Cannot call method on errors are still there.

Copy link
Member

@ondrejmirtes ondrejmirtes left a 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()),
Copy link
Member

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.

Copy link
Contributor Author

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.

@ondrejmirtes
Copy link
Member

Hi, I'm sorry, you'll have to debug it yourself, I can't dive into this right now.

@ruudk
Copy link
Contributor

ruudk commented Feb 9, 2021

Can be closed as #172 is merged.

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.

3 participants