A value is compared with true, or loosely with false
What it finds
if ($done == true) and $x === true: comparing with true adds nothing to a value that is already a boolean, and a loose comparison with true or false hides what the value really is. === false, which tells false from 0 and '', is left alone.
From the rule's source, boolean_literal_comparison.rs.
<?phpfunction check($done, $pos){ if ($done == true) {tx0 reports: a value is compared with a boolean literal return 1; } if ($done === true) {tx0 reports: a value is compared with a boolean literal return 2; } return $pos === false;} Turn it on, off or suppress it
The rule runs from the all tier up. To turn it on in a lower tier, give it a level in tx0.toml:
[rules]
"tx0/php:boolean-literal-comparison" = "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:boolean-literal-comparison] reason="..."tx0 explain tx0/php:boolean-literal-comparison shows the same in the terminal. Found a false positive? Report it.