php-modern-prolisted
Install: claude install-skill hmj1026/dhpk
# PHP modern pro — 7.4 baseline + dual-floor library design
This skill is the **counterpart to `php-pro`** (which assumes PHP 5.6 and
forbids ≥7.0 syntax). Load it when working on code that targets PHP 7.4
or a library that intentionally spans 7.x→8.x.
`modules/php-7.4/references/static-checks.md` is the always-loaded index
into the tooling tier (php-cs-fixer + phpstan/psalm). This skill is the
**language & packaging companion** — load when designing API shape, picking
idioms, or reviewing composer constraints.
> Rule of thumb: `php-pro` is for legacy monoliths frozen at 5.6.
> `php-modern-pro` is for greenfield 7.4+ code and any composer package
> that ships against a version range.
---
## 7.4 baseline — prefer these idioms
### Typed properties
```php
final class UserId
{
private int $value;
public function __construct(int $value)
{
$this->value = $value;
}
}
```
- Always type properties. Drop PHPDoc `@var` once the property is typed
unless the type is a *narrowed* version of the declared type (e.g.
`array<string, User>` on top of `array`).
- Prefer `final` on value objects and on classes that aren't designed for
inheritance. Subclasses you can't anticipate are subclasses you'll regret.
### Arrow functions
```php
$ids = array_map(fn(User $u): int => $u->id(), $users);
```
- Use for one-expression callbacks. They auto-capture by value.
- Don't reach for `function (…) use (…) {}` unless you need a multi-line
body. Arrow fns make `arr