php-language-modern

Write modern PHP 8.1-8.5 code using enums, property hooks, attributes, and the pipe operator.

1|Updated Jul 29, 2026
One-click install
npx skills add https://github.com/fusengine/kimi-code --skill php-language-modern-fusengine
Or copy as Structured Prompt for Agentβ–Ό
Please help me install this Agent Skill.
Skill: php-language-modern
Source: https://github.com/fusengine/kimi-code/tree/main/plugins/php-expert/skills/php-language-modern
Command: npx skills add https://github.com/fusengine/kimi-code --skill php-language-modern-fusengine

SYSTEM DOCUMENTATION & REQUIREMENTS

πŸ’‘ This Skill includes references (resource) components.

What problem does it solve? LLMs frequently write PHP in a pre-8.0 style β€” using docblock annotations instead of native attributes, class constants instead of enums, and hand-written getters/setters instead of property hooks. This Skill ensures generated PHP uses the correct modern language features for the project's actual PHP version. ## Core Features & Use Cases - Version-aware feature selection: Covers PHP 8.1 through 8.5 features (enums, readonly, first-class callables, property hooks, asymmetric visibility, lazy objects, pipe operator, clone() with $withProperties, #[\NoDiscard]) and mandates checking composer.json require.php before emitting syntax. - Attributes over docblocks: Dedicated reference for replacing legacy @Route, @ORM\Column, and @deprecated annotations with native #[Attribute] syntax β€” the most common modern-PHP mistake. - Copy-paste templates: Complete working examples of backed enums with interfaces, readonly value objects, and entities using property hooks and asymmetric visibility. - Use Case: You are adding a User entity to a non-framework PHP 8.4 project. The Skill guides the agent to verify the version, then produce a class using public private(set) properties, a validating set hook for email, and a virtual displayName property instead of magic __get. ## Quick Start Write a modern PHP User entity with property hooks and a backed Status enum for my PHP 8.4 project, using attributes instead of docblock annotations.

Frequently Asked Questions about php-language-modern

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use property hooks in PHP 8.4?β–Ό

Property hooks let you define get and set logic directly on a property, replacing __get/__set magic and boilerplate getters/setters. A set hook can validate or normalize values on write, and a virtual get-only property computes values without backing storage.

How to replace Doctrine docblock annotations with PHP attributes?β–Ό

Replace @Route, @ORM\Column, and @Assert annotations with native attribute classes like #[Route('/users', methods: ['GET'])] and #[ORM\Column(type: 'string')]. Attributes are part of the AST, compiler-validated, readable via Reflection, and require no doctrine/annotations dependency.

What is the pipe operator in PHP 8.5?β–Ό

The pipe operator |> passes the left-hand value as the single argument to a callable on the right, enabling left-to-right transformation chains. The right side must be a callable, typically written with first-class callable syntax like trim(...) or a closure.

Can I use PHP 8.5 features on a PHP 8.1 project?β–Ό

No. Features like the pipe operator, clone() with $withProperties, and #[\NoDiscard] require PHP 8.5, while property hooks and asymmetric visibility require 8.4. Always check composer.json require.php first and verify feature versions on php.net before emitting syntax.

When should I use enums instead of class constants in PHP?β–Ό

Use backed enums for any closed set of values since PHP 8.1. Enums carry type safety, support methods and interfaces, and work with match expressions, whereas class constants are untyped and cannot encapsulate behavior.

When should I not use this modern PHP language skill?β–Ό

Do not use it for coding style, PSR compliance, or autoloading questions β€” those belong to a PHP standards skill. It also excludes Laravel-specific syntax conventions, which are covered by the Laravel plugin.