Open xPaw opened 2 years ago
thx for reporting. does your real world example really contains a array of literal strings above the loop? or will it be more complex then that?
I am asking, because we might fix the case you reported, while not fixing your actual problem in case the above example is not realistic
does your real world example really contains a array of literal strings above the loop?
I did have an array of queries to run, yeah.
I think this could be fixed by resolving the query expression type and look whether it contains a constant string.
if so, return immediately in https://github.com/staabm/phpstan-dba/blob/6bd6e84331c6e15d76868e14444ed20c2aab06b9/src/QueryReflection/QueryReflection.php#L148
Thinking more about it.. a example with more then 1 query is more obvious.
Within the loop the result of the query function would be a union of all possible result types, not just a single one as the initial example might suggest -> https://github.com/staabm/phpstan-dba/pull/290
However this doesn't crash:
Something about the loop makes it confuse the type. Obviously reusing the variable isn't a good idea (and I fixed it in my code), but it probably shouldn't crash.