← ClaudeAtlas

php-modern-prolisted

PHP 7.4 → 8.x modern idioms and dual-version-floor library packaging. Use when writing or reviewing PHP code that targets ≥7.4 (typed properties, arrow fns, null-coalesce assignment, spread in arrays, numeric literal separator) or a composer package whose constraint spans 7.x→8.x (where 8.0+ features like match / nullsafe / named args / attributes / readonly / enums must be used conditionally). Also covers polyfill / class_alias / autoload-time runtime-detection patterns for libraries that span Monolog 2/3, Laravel 6→11, Flysystem 1→3, or similar dual-major-version dependencies. Counterpart to php-pro (which targets 5.6 baseline and forbids ≥7.0 syntax). Not for everyday business logic — load when designing a public API, picking between a 7.4 and an 8.x idiom, writing a polyfill / version-conditional shim, or reviewing composer.json constraint hygiene.
hmj1026/dhpk · ★ 1 · AI & Automation · score 72
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