Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.language

Use only one default case per switch

A switch statement must not declare more than one default branch.

#Metadata

Rule ID
php.correctness.switch-multiple-default
Severity
high
Confidence
0.98
Languages
php
Presets
strict
Stability
stable
Applies to
block
Tags
correctness, php, rules-catalog

#Why it matters

Multiple default cases are invalid PHP and indicate a copy-paste or merge mistake.

#Remediation

Keep a single default case and move additional logic into earlier cases or refactor the control flow.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/php/php.correctness.switch-multiple-default.rule.yaml.