An assignment is combined with and, or or xor, which bind more loosely than =
What it finds
$ok = $a and $b;: and, or and xor bind more loosely than =, so this assigns $a and then combines the result with $b, which is dropped. && or parentheses were meant. The idiom $f = fopen($p) or die(...), where the right side only reacts to failure, is left alone: a right side that calls something, exits or throws is not reported.
From the rule's source, low_precedence_assignment.rs.
<?phpfunction flags($a, $b, $path){ $both = $a and $b;tx0 reports: $both gets only the left operand of and $either = $a or $b > 1;tx0 reports: $either gets only the left operand of or $file = fopen($path, 'r') or die('cannot open'); $ok = ($a and $b); $fine = $a && $b; return [$both, $either, $file, $ok, $fine];} Turn it on, off or suppress it
The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:
[rules]
"tx0/php:low-precedence-assignment" = "off"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:low-precedence-assignment] reason="..."tx0 explain tx0/php:low-precedence-assignment shows the same in the terminal. Found a false positive? Report it.