-
Notifications
You must be signed in to change notification settings - Fork 49
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
Check for boolean in while conditions #260
base: 2.0.x
Are you sure you want to change the base?
Conversation
a48f7f2
to
81e96e5
Compare
ca0151c
to
c9218d4
Compare
Friendly ping @ondrejmirtes if you find some time 👍 |
rules.neon
Outdated
@@ -64,12 +64,16 @@ conditionalTags: | |||
phpstan.rules.rule: %strictRules.booleansInConditions% | |||
PHPStan\Rules\BooleansInConditions\BooleanInBooleanOrRule: | |||
phpstan.rules.rule: %strictRules.booleansInConditions% | |||
PHPStan\Rules\BooleansInConditions\BooleanInDoWhileConditionRule: | |||
phpstan.rules.rule: %strictRules.booleansInConditions% |
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.
This is a new rule. It has to be part of bleeding edge. See how this was done in 1.x:
phpstan-strict-rules/rules.neon
Line 20 in b564ca4
disallowedLooseComparison: [%strictRules.allRules%, %featureToggles.bleedingEdge%] |
This also means this needs a new config parameter. Something like booleansInLoopConditions?
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.
Sure, should be ok now
87b2584
to
fa0879c
Compare
Might be enough to close #259
I tried to implement the same thing for
For_
.But the issue I encounter in
is that
$i
is considered as a MixedType, which is non explicit, soBooleanHelper::passesAsBoolean
always return true.So i'm unsure the rule is doable for
for
loops.