php-8x-featureslisted
Install: claude install-skill hmj1026/dhpk
# PHP 8.x features — additive on top of 7.4
This skill assumes you've read or have access to
`modules/php-7.4/skills/php-modern-pro/SKILL.md`. That skill covers 7.4
baseline + dual-version-floor library patterns. This skill adds the 8.x
features and the **library-author rule** for each: when can you use it
unconditionally, when must you gate it.
> Mental model: every 8.x feature is **syntax**, not runtime. There is
> no polyfill. If the constraint floor is 7.x, the code is a parse error
> on 7.x runtimes — you cannot wrap it in a `function_exists` check.
---
## 8.0 features
### `match` expression — min PHP 8.0
```php
$label = match ($code) {
100, 200, 300 => 'success',
404 => 'not found',
500 => 'server error',
default => 'unknown',
};
```
- Strict comparison (`===`), unlike `switch`'s loose `==`.
- Each arm is an *expression* — returns a value. The whole `match`
evaluates to that value.
- Missing default + unhandled value throws `UnhandledMatchError`. This
catches bugs that `switch`'s silent fall-through hides.
- **Library rule**: gate to apps with PHP floor ≥8.0. Don't ship in a
`^7.4 \|\| ^8.0` library — `switch` is the right idiom there.
### Nullsafe `?->` — min PHP 8.0
```php
$city = $user?->profile?->address?->city ?? 'unknown';
```
- Chain stops at the first `null`; the whole expression evaluates to
`null`. Pair with `??` for a default.
- Only works on method/property access, not array indexing
(`$arr['k']?-