Use benevolent union for scalar in queries#447
Use benevolent union for scalar in queries#447VincentLanglet wants to merge 8 commits intophpstan:1.3.xfrom
Conversation
1dbf6fd to
b4c3152
Compare
|
Hi, I need tests to understand what will this fix :) I'd say we need benevolent union even for the case without |
I added benevolent union in two situations so far:
I updated the tests (about int|numeric-string) and added one test about where conditions @ondrejmirtes. |
0e7b673 to
86e52ac
Compare
Does this solution seems ok to you @ondrejmirtes ? This should avoid false positive from #412 but still be an improvement of query results. And possibly allow you to make new releases, unless you find others issues. :) |
|
FYI I had to revert some of your commits so I can release phpstan-doctrine with other changes. Unfortunately I currently cannot give this the work priority and the needed timeframe of multiple days in order to finish this. 84bf895...f1499e5 |
I understand. I recreated the PR with the commits reverted #453 then |
This PR could be an idea of solution for #446
I assume that before #412, the resultType of Query were less used a lot so we didn't have a lot of feedback about the type resolution. But I tried to reproduce your "bug", and even the merge of my PR
were reporting
list<array{id: int|numeric-string|null}>. I just give the same result withgetArrayResultnow.For Identity, I found some specific solution to improve the return type,
but still, I anticipate a lot of similar issue with results like
which is reported as
list<array{id: int|null}>when we would expectlist<array{id: int}>. Notice that in the same way, before #412, the query was already returninglist<array{id: int|null}>forgetResultcalls.Since we currently cannot be sure that all those
|nullare true because, for example, we don't check theWHEREcondition (and this would be complex). I think the best solution so far would be to use BenevolentUnion for this instead of default unions.Before fixing the tests I'd like your opinion on such change.