-
Notifications
You must be signed in to change notification settings - Fork 461
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
Truthy isset($arr[$k])
should narrow $k
#3453
Conversation
I am puzzled by the test and its expectations: phpstan-src/tests/PHPStan/Rules/Variables/data/bug-10577.php Lines 9 to 27 in cb8f910
I feel the assertion in this test is wrong, see https://3v4l.org/WD7OG |
src/Analyser/TypeSpecifier.php
Outdated
@@ -818,6 +818,60 @@ public function specifyTypesInCondition( | |||
$rootExpr, | |||
), | |||
); | |||
} elseif ($var->dim instanceof Expr\Variable) { |
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.
Doesn't have to be just a variable. Getting rid of instanceof
like these leads to bugfixes:
- d3a2a92?w=1
- 00d2caf?w=1 (regression tests in a follow-up commit)
This pull request has been marked as ready for review. |
in a followup I will look into implications for $k in |
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.
I think this is solid enough to merge this :) One more thing: regression test for phpstan/phpstan#8559 please.
Thank you! |
closes phpstan/phpstan#11716
closes phpstan/phpstan#8559
see https://www.php.net/manual/en/language.types.array.php