Duplicate condition branches (ARCH7190)
Esta página aún no está disponible en tu idioma.
Key php.quality.duplicate-branches · Severity warning · Category quality
Branches with identical bodies are usually a copy-paste mistake or a redundant branch. Merge the branches or extract the shared logic.
Incorrect
Section titled “Incorrect”<?phpfunction fee(string $tier): float{ if ($tier === 'gold') { return 0.0; } elseif ($tier === 'platinum') { return 0.0; } return 5.0;}Correct
Section titled “Correct”<?phpfunction fee(string $tier): float{ if (in_array($tier, ['gold', 'platinum'], true)) { return 0.0; } return 5.0;}Combine branches with identical bodies into one condition, or extract the shared logic.