Skip to content

Doctrine QueryBulder typehint #5

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

Closed
simPod opened this issue Jun 18, 2017 · 4 comments
Closed

Doctrine QueryBulder typehint #5

simPod opened this issue Jun 18, 2017 · 4 comments

Comments

@simPod
Copy link
Contributor

simPod commented Jun 18, 2017

Level 5 gives me such warnings: Parameter #4 $condition of method Doctrine\ORM\QueryBuilder::leftJoin() expects string|null, Doctrine\ORM\Query\Expr\Andx given

That happens when you dont use simple string conditions like this ->leftJoin('u.Phonenumbers', 'p', Expr\Join::WITH, 'p.is_primary = 1'); while joining but when using Expr builder instead. QueryBuilder's join functions document that argument as string|null but it also takes Expr

Do you think I should mark this warning as ignored?

@stesie
Copy link
Contributor

stesie commented Aug 13, 2017

Well, the type signature of leftJoin clearly states string|null, and not some object. So if at all I think this is an issue with Doctrine ORM itself ... and it just works because the type implicitly is coerced to string.

On the project I'm currently on, we didn't mark the warning as ignored, but just explicitly cast the object to string, which calls the object's __toString() method.

@ondrejmirtes
Copy link
Member

Yes, agreed, you should open a PR with Doctrine to update their phpDocs :)

@simPod
Copy link
Contributor Author

simPod commented Dec 8, 2017

I was looking into doctrine docs and I think it's better to cast to string as @stesie mentioned. For doctrine it would require huge rework for phpdocs. I believe it will improve with new doctrine major version

@github-actions
Copy link

github-actions bot commented May 2, 2021

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 May 2, 2021
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

3 participants