Agent-skills-standard php-language
Apply core PHP language standards and modern 8.x features. Use when working with PHP 8.x features like enums, fibers, readonly properties, or named arguments. (triggers: **/*.php, declare, readonly, match, constructor, promotion, types)
install
source · Clone the upstream repo
git clone https://github.com/HoangNguyen0403/agent-skills-standard
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/HoangNguyen0403/agent-skills-standard "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/php/php-language" ~/.claude/skills/hoangnguyen0403-agent-skills-standard-php-language && rm -rf "$T"
manifest:
skills/php/php-language/SKILL.mdsource content
PHP Language Standards
Priority: P0 (CRITICAL)
Structure
src/ └── {Namespace}/ └── {Class}.php
Implementation Guidelines
Core Language Standards
- Strict Typing: Declare
at very top of every file.declare(strict_types=1); - Type Hinting: Apply scalar type hints (e.g.,
,string
) and return types to all functions.int - Strict Comparison: Avoid loose
comparison; always use==
for strict equality.===
Modern PHP 8+ Patterns
- Match Expressions: Prefer
overmatch($status)
for value returns. It provides strict comparison and exhaustive by default.switch - Default Case: Use
to handle unknown states.default => throw new InvalidArgumentException($status) - Read-only: Use
for properties set once at construction.public readonly string $name - Property Promotion: Use
to reduce boilerplate.public function __construct(public string $name) {} - Named Arguments: Call functions with
to skip optional parameters.name: 'John', age: 25 - Flexible Types: Use Union types (
) and Intersection types (int|string
).Countable&Traversable
Anti-Patterns
- No untyped functions: Declare return and parameter types always.
- No loose
comparison: Use==
for strict equality.=== - No
for value mapping: Useswitch
expressions instead.match - No global namespace logic: Organize in classes and namespaces.