-
Notifications
You must be signed in to change notification settings - Fork 523
Fix AccessPropertiesCheck for checkThisOnly #4117
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
47672fd
to
1f7e3be
Compare
1f7e3be
to
1fe7871
Compare
Why is this error happening only on level 1 right now? I don't get it. |
Also I'm worried that if you just silence this situation for checkThisOnly=false, it will still happen in: https://phpstan.org/r/c822e0d3-9d45-4531-aced-23ce661afdcb |
I just don't get why is this happening, please explain how you debugged this :) |
The "special check" for phpstan-src/src/Rules/Properties/ReadingWriteOnlyPropertiesRule.php Lines 45 to 51 in cb331f5
The fact is the line
So then the early return
only works for level > 1. And why do we get
in phpstan-src/src/Rules/RuleLevelHelper.php Lines 168 to 181 in cb331f5
I tried first to change the early return in the rule to
but some tests are failing which missing error like
|
I noticed that the conditions in AccessPropertiesCheck are wrong. This is the concerning line:
The error CANNOT be reported when Additionally, I synced up the rest of the condition with the callback passed to So now, the callback says: static fn (Type $type) => !$type->toString() instanceof ErrorType && $type->toString()->isString()->yes() And the whole condition after is: if (
!$nameType instanceof ErrorType
&& (
$nameType->toString() instanceof ErrorType
|| !$nameType->toString()->isString()->yes()
)
) { See the commit: 81a8d34 This is how all the other occurences of findTypeToCheck work. So the issue had nothing to do with checkThisOnly. The fact that errors about |
/cc @zonuexe |
Closes phpstan/phpstan#13271