match-expression
Installation
SKILL.md
PHP match Expression
When to use
- The user maps a single subject value to a result (status to label, code to message, enum case to behavior) on PHP 8.0+.
- The user needs to handle every case of an enum and wants a compile-time guarantee that no case is missed.
- The user wants to replace a
switchthat assigns or returns a value with a safer construct on PHP 8.0+.
When NOT to use
- Do not use match when the target runtime is PHP 7.4 or earlier; use a value-returning switch or an array map instead.
- Do not use this skill when each branch runs a block of side-effecting statements rather than producing a value.