-
Notifications
You must be signed in to change notification settings - Fork 478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update PhpStorm stubs #3377
Update PhpStorm stubs #3377
Conversation
b398b12
to
a08ba64
Compare
The right solution is to take dynamic throw type extensions into account in But we need to introduce a new virtual node that would wrap |
Oh, we already have this virtual node: NoopExpressionNode Try rewriting the rules by using it. The main rule that uses it is BetterNoopRule and it actually contains skips for situations that are handled by |
Am I wrong or currently NoopExpressionNode doesn't have access to things the StatementResult provides ? |
Doesn't matter, this node is invoked only for expressions with zero throw points. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also rewrite the 3 other rules as well (static call, function, constructor).
src/Rules/Methods/CallToMethodStatementWithoutSideEffectsRule.php
Outdated
Show resolved
Hide resolved
Sure I will, but since tests are still failing, it means that PHPStan still believe there is throwPoints |
src/Rules/Methods/CallToMethodStatementWithoutSideEffectsRule.php
Outdated
Show resolved
Hide resolved
I had to add back the check on NeverType (ff5c552) to solve two tests. The last test was failing because PHPStan consider there is a ImpurePoint (methodCall: call to unknown method) in
Which seems true, I can produce an exception with
|
Thanks a lot for your help @ondrejmirtes, it's now ready for a new review |
Awesome, thank you! |
phpstan/phpstan#11503 (comment) is showing there is a (small ?) impact of the current refacto. A reproducer would be https://phpstan.org/r/37abe2c8-b4bb-4ba6-bb7d-0eedcf703d0c There is an impure point phpstan-src/src/Analyser/NodeScopeResolver.php Lines 3270 to 3281 in 2e27573
There is a DateTimeZoneConstructorThrowTypeExtension
it seems used for DeadCatch detection but not NoSideEffect detection, is there something missing or is this behavior wanted ? Edit: I don't see |
Does If it has the same problem then we should fix both. |
Not sure to understand the question but I'll do my best to answer it:
has
has
has
Which gives https://phpstan.org/r/dfe3ff19-92e9-4d6b-be05-4673be64ffec I expect 0 impure point everywhere |
I say we're fine here, nothing to fix. |
Would you mind develop a bit ?
without assigning the variable doesn't require to be reported ? (and is considering has having side effects) I was planning on adding
in the functionMetadata.php file. (which seems to solve the issue) |
|
So the purity depends on how the arguments look like. And we don't have an extension point for that now. |
Oh, I see. I thought PHPStan had a level between purity and side effect, in a way that
Like https://phpstan.org/r/60731ffd-1e61-4cc0-bfdd-ec8529197b52 But seems like it's not. So indeed, we're "fine" until such feature would be implemented. |
Hi @ondrejmirtes,
I tried to work on the update #3334
First I thought some DynamicMethodThrowTypeExtension was needed but it seems like it is correctly implemented since your PR aa7989f
But the issue is the fact that currently CallToMethodStatementWithoutSideEffectsRule
Does not seems to use those dynamicExtension but rely on
$method->getThrowType()
insteadwhich seems to only rely on the phpdoc of the method.
An example can be found with https://phpstan.org/r/b071a436-7779-47de-816e-d520f4d70bdd, even if the dynamicThrowTypeExtension exists (and say there is no exception with 2 params https://github.com/phpstan/phpstan-src/blob/1.12.x/src/Type/Php/DsMapDynamicMethodThrowTypeExtension.php).
I see 3 solutions:
$method->getThrowType()
, and I'll be happy to update the PR with it. (but which one ?)I'll be happy to try working on this, but so far I have trouble to see if I need to play with the ThrowPoint things or just duplicate the use of DynamicMethodThrowTypeExtension....