plugins/php-expert/skills/php-language-modern/SKILL.md
Use when writing or reviewing modern PHP (8.1–8.5) outside a framework — property hooks, asymmetric visibility, the pipe operator, native attributes, enums, readonly, lazy objects. Covers language features that LLMs frequently get wrong or write in a pre-8.0 style. Do NOT use for coding style/PSR/autoloading (use php-standards) or Laravel-specific syntax (use the laravel plugin).
npx skillsauth add fusengine/agents php-language-modernInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
Before writing PHP, use TeamCreate to spawn 3 agents:
composer.json require.php, CI matrix)After writing, run fuse-ai-pilot:sniper for validation.
| Feature | Since | Use it for |
|---------|-------|------------|
| Enums (backed + methods/interfaces) | 8.1 | Closed sets of values with behavior |
| First-class callable syntax f(...) | 8.1 | Passing callables without strings |
| readonly properties / classes | 8.1 / 8.2 | Immutable value objects / DTOs |
| #[\Override] | 8.3 | Fail-fast on broken inheritance |
| Property hooks get/set | 8.4 | Computed/validated properties, no getter/setter boilerplate |
| Asymmetric visibility public private(set) | 8.4 (static: 8.5) | Public read, restricted write |
| Lazy objects newLazyGhost() | 8.4 | Deferred initialization in DI containers |
| Pipe operator \|> | 8.5 | Left-to-right data transformation chains |
| clone() function + $withProperties | 8.5 | Immutable "with" updates, incl. readonly |
| #[\NoDiscard] | 8.5 | Enforce return-value consumption |
#[Attribute] replaces @annotation docblocks for routing, ORM, DI, validation. This is the #1 LLM mistake — see attributes-over-docblocks.md.composer.json require.php before choosing a feature.readonly + property hooks over hand-written getters/setters — less boilerplate, enforced immutability.declare(strict_types=1); at the top of every file.src/
├── Enum/
│ └── Status.php # backed enum + interface + methods
├── ValueObject/
│ └── Money.php # readonly class, clone() with $withProperties
└── Model/
└── User.php # property hooks, asymmetric visibility
→ See modern-class.md for complete working code
| Topic | Reference | When to Consult |
|-------|-----------|-----------------|
| PHP 8.5 features | php-85-features.md | Pipe operator, clone(), #[\NoDiscard], static aviz |
| PHP 8.4 features | php-84-features.md | Property hooks, aviz, lazy objects, #[\Deprecated] |
| 8.1–8.3 baseline | php-81-83-baseline.md | Enums, readonly, fibers, #[\Override] |
| Attributes vs docblocks | attributes-over-docblocks.md | Any metadata: routing, ORM, DI, validation |
| Template | When to Use | |----------|-------------| | modern-class.md | Writing a new class the modern way |
require.php before picking a feature version__get@Route/@ORM\Column docblock annotations — use attributesreadonly fittesting
Copy self-audit and ban-lists — filler verbs/hype adjectives, slop placeholder names, fake-precise numbers, Title Case headlines, humor in error copy ('Oops!'), em-dash crutch, one copy register per page.
development
Logged-in web apps — dashboards, auth flows, settings, onboarding, data tables, command palettes, modals, toasts. Register `product`: density and glance-speed over marketing polish, no hero/CTA-tricks, every data surface covers empty/loading/error explicitly, tables and dataviz follow preattentive-processing rules.
development
Marketing sites, landing pages, campaign pages — register `brand` (design IS the product). Structure comes from the register's POV + a macrostructure pick, never from copying an inspiration site's section flow. Hero discipline, deviated section order, asymmetric grids, and a silhouette lookalike-test gate before ship.
development
Token-strategy core — OKLCH color rules, neutral tinting, accent-commitment levels, type scale, 8pt spacing grid, touch targets, and the canonical output format of design-system.md (the file the harness gates on). This is routing step 1 of design-method/SKILL.md — read it before design-web/design-webapp/design-ios/design-android, before picking or auditing a single color/type/spacing value.