-
Notifications
You must be signed in to change notification settings - Fork 534
Simplify *StatementWithoutImpurePointsRule #4375
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
Conversation
Oh now we're getting somewhere! Please add these cases as regression tests to the PR that improves the analysis. |
done in 5f3c308 |
I haven't looked at the code when I posted the first comment. I think this is a false positive in #4372. I also think the type When we look at the code: $methods = [];
foreach ($node->get(MethodWithoutImpurePointsCollector::class) as $collected) {
foreach ($collected as [$className, $methodName, $classDisplayName]) {
$className = strtolower($className);
if (!array_key_exists($className, $methods)) {
$methods[$className] = [];
}
$methods[$className][strtolower($methodName)] = $classDisplayName . '::' . $methodName;
}
} On the first iteration, the array is empty. But on 2nd iteration, we don't know what So I think the message "will always evaluate to false" is wrong here. |
I agree with this observation and we shouldn't have this error. the PR as is, still makes sense though, as the array-key-exists before array-append does not serve a purpose IMO: |
Yeah, sure, it can be removed. But please add this piece of code as a regression test to the other PR to make sure this isn't reported there in the end. As for my tip what's causing it: please check that phpstan-src/src/Analyser/NodeScopeResolver.php Line 1213 in e3fd45f
phpstan-src/src/Analyser/NodeScopeResolver.php Line 1237 in e3fd45f
|
Thank you. |
have it here cb8e036 |
while I find more and more side-quest cleanups like #4380 I am not able to figure out a proper fix. I tried invalidating the expressions but it did not solve the |
Found the problem (84b61d4), pushed fix to your PR. |
thank you! |
identified in #4372