-
Notifications
You must be signed in to change notification settings - Fork 430
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
Simulate issset for null coalesce operator #1104
Conversation
Several thing to consider and fix. isset($a) ? $a : null;
isset($a->b) ? $a->b : null;
$a ?? null;
$a->b ?? null; are all valid (no errors, but kind of buggy), currently PHPStan throws an error Also, it may be misleading, if |
I should separate the PR for 6870 |
1562e4b
to
148f35e
Compare
148f35e
to
ba47a41
Compare
5 errors in tests
2, 3, 5. Fixes phpstan/phpstan#6809 and some others but conflicting with the current test case
|
The failures in the tests looks good to me, but it's definitely a breaking change.
By the way, there is a bug in coalesce too, reported in phpstan/phpstan#5971 (comment) $this->field->prop ?? false would not be recognized as read for property
As explained in phpstan/phpstan#6809 (comment) This commit cf0059e |
I think first one should be fixed, but not sure about the second one. |
Please see my thinking about this: phpstan/phpstan#6809 (comment) I don't want BC breaks around this for analysis on PHP <= 8.1. We can do something more ambitious and strict for PHP 8.2 and objects that do not allow dynamic properties, but right now, there are too many test failures :) |
@ondrejmirtes |
…ign` from `Coalesce`" This reverts commit cf0059e.
…sionAllowed from isInExpressionAssign
fixes phpstan/phpstan#6107 fixes phpstan/phpstan#5971 fixes phpstan/phpstan#6899
Superseded by #1192 |
fixes phpstan/phpstan#4885
fixes phpstan/phpstan#5304
fixes phpstan/phpstan#5337