Remember resolved types after pushInFunctionCall#4648
Remember resolved types after pushInFunctionCall#4648ondrejmirtes merged 5 commits intophpstan:2.1.xfrom
Conversation
ondrejmirtes
left a comment
There was a problem hiding this comment.
- Could be in popInFunctionCall too
- BUT:
$this->inFunctionCallsStackis used in resolveType() in} elseif ($node instanceof Expr\Closure || $node instanceof Expr\ArrowFunction) {so that could be a problem (the problem should be reproduced in a test first).
|
Issue bot points out an example where this breaks https://phpstan.org/r/dfc26675-234f-47b3-8d0f-dc64b66ef5aa |
I think this problem was caught by existing tests, as the suite failed with the change until I got it right. |
|
This pull request has been marked as ready for review. |
|
Perfect! Thank you. My idea for preserving This logic doesn't have to be called in methods like And the implementation of preserveResolvedTypes would look at changes between This logic is very similar to what Do you think you want to look into this? |
|
I can have a look |

prevents duplicate work, as MethodCalls will re-calculated one less time.
analysing
before this PR reaches “if ($node instanceof MethodCall) {“ in MutatingScope.php:2161 4 times.
after the PR only 3 times.
with
PHPSTAN_FNSR=1 php bin/phpstan analyze foo.php --debugafter PR its only 2 times.