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
Feature/undefined expression allowed #1174
Feature/undefined expression allowed #1174
Conversation
I'm blown away by this, it's awesome! Additionally, I love when people start working on a change X (#1104), realize that changeset Y can be contributed separately (#1174) and once it's merged, they go back to implementing X again :) I'm ready to merge this, I just want to ask you to add regression tests for the linked issues you know this fixes. |
Also - consider basing this on 1.5.x since it can be considered a bugfix for all those issues. |
I'm happy to hear your comments! I think I need two more fixes and can finally complete #1104 :) |
I'll fix and add tests and do some small refactoring today. I'll mark it ready when it's finished! |
The failing integration test is from |
cd29f92
to
641ea52
Compare
…sionAllowed from isInExpressionAssign
fixes phpstan/phpstan#6107 fixes phpstan/phpstan#5971
641ea52
to
db78bf5
Compare
Rebased and added some regression tests. This PR is ready for review! |
I'll fix this one next phpstan-src/tests/PHPStan/Rules/Properties/AccessPropertiesRuleTest.php Lines 573 to 576 in db78bf5
and fix TypeSpecifier for Isset_ . Then complete #1104 👍
|
Awesome, thank you! |
fixes phpstan/phpstan#6107
fixes phpstan/phpstan#5971
fixes phpstan/phpstan#5337
fixes phpstan/phpstan#6899
This PR introduces a new method
isUndefinedExpressionAllowed
toScope
interface and new propertycurrentlyAllowedUndefinedExpression
ofMutatingScope
.Currently, access to undefined property is allowed in assign. In
Isset_
andEmpty_
it is simulating an assign bylookForEnterExpressionAssign
to avoid undefined propeties, but it changes from read access to write access which are causing false positives/negatives like issues in above.The purpose of this feature is to separate
isInExpressionAssign
and undefined property to avoid those issues.Also, this feature can make allowing/disallowing undefined expressions much more flexibly like 59d89a5
(this line is added for backwards compatibility that
Coalesce
doesn't allow dynamic properties)and may be easier to make strict analysis after
#[AllowDynamicProperties]
is introduced in PHP 8.2 :)#1104 (comment)