A switch or match lists the same value twice
What it finds
case 'a': ... case 'a': and match ($x) { 1 => ..., 1 => ... }: a value listed twice in one switch or match can only reach the first of its arms; the second is dead, and usually stands for a value that was meant instead.
From the rule's source, duplicate_case.rs.
<?phpfunction label($status){ switch ($status) { case 'open': return 1; case 'closed': return 2; case 'open':tx0 reports: 'open' is listed twice return 3; } return match ($status) { 1, 2 => 'low', 3 => 'mid', 2 => 'again',tx0 reports: 2 is listed twice default => 'other', };} 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:duplicate-case" = "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:duplicate-case] reason="..."tx0 explain tx0/php:duplicate-case shows the same in the terminal. Found a false positive? Report it.