PHP language conventions, modern idioms, and type system. Invoke whenever task involves any interaction with PHP code — writing, reviewing, refactoring, debugging, or understanding PHP projects.
Installer avec Codex ou Claude Copiez ce prompt, collez-le dans Codex, Claude ou un autre assistant, puis laissez-le vérifier la page du skill et l'installer pour vous.
Une commande directe contourne le prompt de vérification. Examinez la source avant de l'exécuter.
PHP language conventions, modern idioms, and type system. Invoke whenever task involves any interaction with PHP code — writing, reviewing, refactoring, debugging, or understanding PHP projects.
PHP
Strict types, explicit contracts, no magic. If a class needs a docblock to explain what its properties do, the
properties are named wrong.
PHP 8.5+ is the baseline. Use modern syntax unconditionally — union types, enums, readonly classes, property hooks,
named arguments, match, pipe operator. No backward compatibility with older PHP versions unless the project explicitly
requires it.
Every PHP file starts with declare(strict_types=1).
References
Type system → ${CLAUDE_SKILL_DIR}/references/typing.md — Union/intersection/DNF types, nullable patterns, typed
properties and constants, coercion rules, variance
Abbreviations as words.HttpClient not HTTPClient, JsonParser not JSONParser. Treat abbreviations and
acronyms as regular words — uppercase first letter only (PER-CS).
No underscore prefix for protected/private visibility. Visibility modifiers exist for that.
Type Declarations
PHP 8.5+ provides a complete type system. Use it everywhere.
Core Rules
Type all public API boundaries — function parameters, return types, class properties, class constants.
Internal/private code benefits from types too.
declare(strict_types=1) in every file. No exceptions.
Short type names:bool, int, float, string. Never boolean, integer, double.
Union types with |:string|int, Foo|null. Prefer ?T for single-type nullable.
Intersection types with &:Countable&Traversable. Class/interface types only.
DNF types:array|(ArrayAccess&Traversable) — union of intersections in parentheses.
void return: annotate on functions that return nothing.
never return: functions that always throw or exit.
Avoid mixed — it disables type safety. Use object when you mean "any object." Use mixed only at true interop
boundaries with untyped code.
null last in unions:string|int|null, not null|string|int.
Typed Properties
Every class property gets a type declaration.
Typed properties must be initialized before access — use constructor promotion, default values, or constructor
assignment.
callable cannot be used as a property type. Use Closure instead.
Order: <?php tag, blank line, declare(strict_types=1), blank line, namespace, blank line, use imports (classes,
then functions, then constants), blank line, code. No leading backslash on imports.
See ${CLAUDE_SKILL_DIR}/references/packaging.md for composer.json templates and PSR-4 mapping.
Formatting (PER-CS)
PER Coding Style is the baseline. These are conventions, not tool configuration.
4-space indentation. No tabs.
Opening braces on their own line for classes, interfaces, traits, enums, methods.
Opening braces on the same line for control structures (if, for, while, etc.).
One statement per line. No multi-statement lines.
Soft line limit: 120 characters. Prefer 80 for readability.
Trailing commas on multi-line argument lists, arrays, match arms, use lists.
No trailing commas on single-line constructs.
Visibility on everything — properties, methods, constants.
new Foo() — always use parentheses when instantiating (even without arguments), unless immediately chaining:
new Foo()->method().
Compound types: no spaces around | and &. Parentheses for DNF without internal spaces.
Empty exception classes on one line: class NotFoundException extends AppException {}
Application
When writing PHP code: apply all conventions silently — don't narrate each rule. If an existing codebase contradicts
a convention, follow the codebase and flag the divergence once.
When reviewing PHP code: cite the specific violation and show the fix inline. Don't lecture — state what's wrong and
how to fix it.
Bad: "According to PHP best practices, you should use strict_types
declaration at the top of every file..."
Good: "Missing declare(strict_types=1)."
Code Navigation — LSP Required
An Intelephense LSP server is configured for .php and .phtml files. Always use LSP tools for code navigation
instead of Grep or Glob. LSP understands PHP's namespace system, type inference, scope rules, and Composer autoload
boundaries — text search does not.
Tool Routing
Find where a function/class is defined → goToDefinition — resolves use statements, aliases, namespace paths
Find all usages of a symbol → findReferences — scope-aware, no false positives from string matches
Get type signature or docs → hover — instant type info without reading source files
List all symbols in a file → documentSymbol — structured output: classes, methods, constants
Find a symbol by name across project → workspaceSymbol — searches all namespaces and Composer dependencies
Find concrete classes implementing an interface → goToImplementation — knows the type hierarchy
Find what calls a function → incomingCalls — precise call graph across namespace boundaries
Find what a function calls → outgoingCalls — structured dependency map
Grep/Glob remain appropriate for: text in comments, string literals, log messages, TODO markers, config values, env
vars, file name patterns, URLs, error message text — anything that isn't a PHP identifier.
When spawning subagents for PHP codebase exploration, instruct them to use LSP tools. Subagents have access to the same
LSP server.
Integration
The coding skill governs workflow (discovery, planning, verification); this skill governs PHP implementation
choices. The phpunit skill governs testing conventions — both are active simultaneously when writing PHP tests.
Strict types everywhere. Types on everything. If PHP can check it at compile time, make it do so.