Repository navigation
Improve create conditional expressions to handle all expressions - #2007
Conversation
d17c4c1 to
5b9cf52
Compare
|
Issue bot seems not working well. Looks like a cache problem? |
hmm I have the impression it works: |
|
Oh, thank you for noticing! Not sure what I was looking at... |
|
@ondrejmirtes |
|
Loops are generalised and skipped after a couple of iterations AFAIK. Could that be related? |
|
Not that "loop" I think. |
fa64209 to
e3c84ef
Compare
|
Ah sorry, yeah, completely wrong loop I was thinking about.. xD |
472df61 to
b2bea90
Compare
|
This pull request has been marked as ready for review. |
|
Thank you! |
| return $field; | ||
| } | ||
|
|
||
| if (count($row) === 2) { |
There was a problem hiding this comment.
This PR seems to cache result of function result 1:1 and retrive the result from cache later. I observed this in phpstan v 1.9.2 (the latest rel).
Is that desired? For count() it is legit and thank you. However for expression like TraitUtil::hasTrait($object, DebugTrait::class) (a custom function) how does php know/guarantee the result will be the same, does it reason it based on the TraitUtil::hasTrait impl or just guess it when the passed args are the same?
There was a problem hiding this comment.
Yes this is intended
how does php know/guarantee the result will be the same
When
- TraitUtil::hasTrait is not marked impure
- The exact same
TraitUtil::hasTrait($object, DebugTrait::class)is called - $object is not invalidated
just guess it when the passed args are the same?
so it's something like that.
There was a problem hiding this comment.
By the way, remembering function results was working before this PR already.
https://phpstan.org/blog/remembering-and-forgetting-returned-values
this PR made them work for more complex conditions too.
There was a problem hiding this comment.
Thank you, I did not know user functions are "pure"/remembered by default.
There was a problem hiding this comment.

This pull request covers
phpstan/phpstan#8360
improves result of phpstan/phpstan#4173 but not completely fixed yet