← ClaudeAtlas

dhpk-php-modern-prolisted

PHP 7.4–8.x idiom and dual-version library-packaging guidance. Use for public APIs, version-conditional shims, supported floors, or composer constraints. Not for routine business logic. Output: a compatibility decision and verification gates.
hmj1026/dhpk · ★ 2 · AI & Automation · score 71
Install: claude install-skill hmj1026/dhpk
# PHP modern pro — 7.4 baseline + dual-floor library design This skill is the **counterpart to `dhpk-php-runtime-router`** (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: `dhpk-php-runtime-router` is for legacy monoliths frozen at 5.6. > `dhpk-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 m