Implement ParameterOutTypeExtensions#3083
Conversation
|
This pull request has been marked as ready for review. |
|
I am not yet sure this feature is useful for the preg_match inference, because the type depends on context: https://github.com/phpstan/phpstan-src/pull/2589/files#diff-65e7da030813493bd5e549d34d89e84b206ed1f44cfc490ffaa52dcba136bd9bR128 |
|
Thinking more about it: maybe we need a param out type which depends on the function call return type for the preg_match case |
|
My question is: How important that is? Can it work without this condition in the first release? I have some ideas but it'd require some exploration (conditional types). |
we will see when looking into it. I think this PR as is also makes sense in general. I think conditional param-out types could work. |
d7fcc22 to
b872fd6
Compare
src/Analyser/NodeScopeResolver.php
Outdated
There was a problem hiding this comment.
why does this code path only exec on variables and not e.g. on PropertyFetch?
There was a problem hiding this comment.
You can explore that in another PR.
src/Analyser/NodeScopeResolver.php
Outdated
There was a problem hiding this comment.
Will this realistically ever return multiple types? I feel like the union should be done inside this method, and the method should return ?Type.
src/Analyser/NodeScopeResolver.php
Outdated
There was a problem hiding this comment.
You can explore that in another PR.
54481e3 to
2b593ec
Compare
There was a problem hiding this comment.
We've recently started dropping the "dynamic" part of the name from an extension. See FunctionParameterClosureTypeExtension for example.
Since you're also applying it here inconsistently (you're not mentioning "dynamic" in the PR title, and also LazyParameterOutTypeExtensionProvider doesn't contain it), please drop it from all the names in this PR. Thanks.
|
Thank you! |
refs #2589 (comment)