match expression edge cases worth knowing
match uses strict comparison (===) unlike switch. That change alone is enough to justify migrating switch statements but there are some behaviors that surprised me.
match throws UnhandledMatchError when no arm matches and there is no default. switch falls through to nothing silently.
Multiple conditions can share one arm: match($status) { “active”, “trial” => true, default => false }. Cleaner than repeating the same result for similar inputs.
Complex conditions in match arms: match(true) { $x > 10 => "high", $x > 0 => "medium", default => "low" }. This pattern replaces if-elseif chains with something more readable.
Match arms are short-circuited: they are not all evaluated, just like if-else. This matters if arms have side effects (they should not, but legacy code sometimes has them in switch cases).
The no-fall-through behavior eliminates the common switch bug where you forget a break and execution falls into the next case. PHP developers have been burned by that for 25 years.
```php blocks are runnable.