Repository navigation
Report implicit mixed in boolean conditions on level 10 - #340
Open
mkantautas wants to merge 1 commit into
Open
mkantautas wants to merge 1 commit into
mkantautas wants to merge 1 commit into
Conversation
VincentLanglet
approved these changes
Oct 23, 2026
staabm
approved these changes
Oct 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #253
Fixes #289
BooleanRuleHelper::passesAsBoolean()returned early for everyMixedType, so implicit mixed passed regardless ofcheckImplicitMixed. On level 10, conditions on untyped parameters or on values of untyped arrays were never reported, while the same code witharray<mixed>was.Following option 3 from #253, explicit mixed is still reported on every level, and implicit mixed now goes through
RuleLevelHelper::findTypeToCheck(), so it is reported only whencheckImplicitMixedis enabled (level 10).ErrorTypekeeps passing as before, so an expression that already has an error (unknown function, undefined variable) does not get a second one.This covers every rule using the helper:
if,elseif, ternary,!,&&,||, and the loop conditions when they are enabled. Levels 0–9 are unchanged. Level 10 users get new*.condNotBooleanerrors for these conditions; the change is not behind bleeding edge.Tests:
tests/Levels/data/onlyBooleans.phpgets the #253 and #289 cases plus unknown-function and undefined-variable controls. The newonlyBooleans-10.jsonfails on 2.1.x.make lint,make tests,make phpstanandmake cspass, and tests and PHPStan pass on PHP 7.4–8.5 with lowest and highest dependencies.