تخطَّ إلى المحتوى

Duplicate condition branches (ARCH7190)

هذا المحتوى غير متوفر بلغتك بعد.

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.

<?php
function fee(string $tier): float
{
if ($tier === 'gold') {
return 0.0;
} elseif ($tier === 'platinum') {
return 0.0;
}
return 5.0;
}
<?php
function 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.