A conditional expression picks between true and false
What it finds
$valid ? true : false: a conditional that picks true or false is its condition converted to a boolean, and !$x for the reverse. The fix writes (bool) or !.
From the rule's source, redundant_boolean_conditional.rs.
<?phpfunction flags($a, $b){ $x = $a > $b ? true : false;tx0 reports: this conditional picks between true and false $y = $a ? false : true;tx0 reports: this conditional picks between true and false $z = $a ? 'yes' : 'no'; return [$x, $y, $z];} Turn it on, off or suppress it
The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/php:redundant-boolean-conditional" = "warning"To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:
// tx0: ignore[tx0/php:redundant-boolean-conditional] reason="..."tx0 explain tx0/php:redundant-boolean-conditional shows the same in the terminal. Found a false positive? Report it.