-
Notifications
You must be signed in to change notification settings - Fork 91
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
Fix branching querybuilder type inference #552
Conversation
No, the problem is in https://github.com/phpstan/phpstan-doctrine/blob/1.4.x/src/Type/Doctrine/QueryBuilder/QueryBuilderType.php - it should override the |
c883c54
to
68c07ca
Compare
e852517
to
cd4f234
Compare
I'm not sure to understand why it's QueryBuilderType. I tried to debug more and it's not called. But after more debugging, I find out that during the execution of As shown in my latest commit the This seems correct to me but some others tests are failing https://github.com/phpstan/phpstan-doctrine/actions/runs/8233591779/job/22513364391?pr=552:
WDYT @ondrejmirtes, do you agree with this analyse/new direction ? |
012a772
to
4c58a40
Compare
The only failing test is the following one: $branchingQuery = $this->getBranchingQueryBuilder($em)->getQuery();
assertType('Doctrine\ORM\Query<null, QueryResult\Entities\Many>', $branchingQuery); I get 'Doctrine\ORM\Query<null, QueryResult\Entities\Many>|Doctrine\ORM\Query<null, QueryResult\Entities\Many>' now. This is kinda true because, if I call $branchingQueryDQL = $this->getBranchingQueryBuilder($em)->getQuery()->getDQL();
assertType('\'SELECT m FROM QueryResult\\Entities\\Many m\'|\'SELECT m FROM QueryResult\\Entities\\Many m WHERE m.intColumn = 1\'', $branchingQueryDQL); Should we:
|
Now phpstan/phpstan-src#2973 is merged, I just need to wait for the next release |
Released now https://github.com/phpstan/phpstan/releases/tag/1.10.63, please update it here |
Done. |
Thank you. |
Hi,
I got an issue with a conditional query like
which was considering to always returning
array<array{intColumn: int}>
which is wrong.After debugging, I thought the issue was coming from
TypeCombinator::union
cf phpstan/phpstan#10694After more debugging, I find out the behavior was different for covariant template or invariant template
https://phpstan.org/r/79c3c099-5d1d-4e36-9cf3-d6028d68415d
So I think the template for Query should not be covariant.
The covariant was added by you @ondrejmirtes in ec49b7a ; do you remember why ?
Thanks