Why this matters
Prevents UnhandledMatchError and makes behavior explicit for future enum/constant additions.
Every match expression must define a default arm that handles unsupported or unexpected values.
Prevents UnhandledMatchError and makes behavior explicit for future enum/constant additions.
Side-by-side examples engineers can pattern-match during review.
$out = match($type) { 'a' => 1, 'b' => 2 };$out = match($type) {
'a' => 1,
'b' => 2,
default => throw new InvalidArgumentException("Unsupported type: {$type}")
};match($x){ 'a'=>1 }match($x){ 'a'=>1, default=>0 }From the same buckets as this rule.
Check if loops use equality operators (== or !=) in termination conditions. These can lead to infinite loops if the condition is never met exactly. Instead, use relational operators like < or > for safer loop termination.