The result of a string comparison function is compared with 1 or -1
What it finds
strcmp($a, $b) == 1: the string comparison functions return a negative number, zero or a positive number, not exactly -1 or 1, so a comparison with 1 or -1 misses most of the cases it means. < 0 and > 0 are what was meant.
From the rule's source, comparison_result_as_one.rs.
<?phpfunction order($a, $b){ if (strcmp($a, $b) == 1) {tx0 reports: strcmp is compared with 1 return 'after'; } if (strcasecmp($a, $b) === -1) {tx0 reports: strcasecmp is compared with -1 return 'before'; } return strcmp($a, $b) > 0 ? 'after' : 'same';} 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:comparison-result-as-one" = "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:comparison-result-as-one] reason="..."tx0 explain tx0/php:comparison-result-as-one shows the same in the terminal. Found a false positive? Report it.