php-coding-standards
FreeNo executable scriptsNot checkedInvoke BEFORE writing or modifying any PHP code. Provides coding standards and naming conventions for Nette repos: TABs, single quotes, strict_types, PER…
About this skill
PHP Coding Standards
Using DressCode
The Nette repositories are checked by DressCode with the dresscode.neon in their root. Install it globally using /php-fixer:install-php-fixer; after that, PHP files are automatically fixed when edited, by that configuration - see the php-auto-fixer skill for editing workflow rules (especially use statement ordering).
General Rules
- Every PHP file must include
declare(strict_types=1) - Use two empty lines between methods - Nette convention for visual separation in longer classes
- Every
@,==and!=carries a comment saying it is deliberate, see below - Multiple exceptions can be written in a single
exceptions.phpfile, and multiple enums intoenums.php - Interface methods don't need visibility as they're always public
- All properties, return values, and parameters must have types
- Final constants don't need types as they're self-evident
- Write all code, comments, and variables in English only (even if communicating with the user in Czech)
Comments for @, == and !=
DressCode reports these operators unless their line ends with a comment in exactly this form:
@unlink($tmp); // @ file may not exist
$content = @file_get_contents($file); // @ is escalated to exception
if ($v != null) { // intentionally !=, skips null and empty string
// @ <reason>: the concrete cause and why it is harmless (a file that may not exist, a disabled function), never a vaguemay trigger error; lower case, no dash, colon or full stop.is escalated to exceptiononly where the code really checks the result and throws// intentionally ==or// intentionally !=, the operator being the one on the line; a reason after a comma only where the intent is not obvious- The comment goes on the line holding the operator, one per line
Strings
- Use single quotes - they signal "no interpolation here," making code easier to scan
- Use double quotes only when the string contains apostrophes or interpolation is needed
- In HTML attributes, double quotes are standard
Naming Conventions
- Avoid abbreviations unless the full name is too long
- Use UPPERCASE for two-letter abbreviations (
IO,DB), PascalCase/camelCase for longer ones (Http,Xml) - Use nouns or noun phrases for class names
- Class names should include both specificity and generality (e.g.,
ArrayIterator) - Never let a method name be a bare noun - a method is an action:
getProvider(), notprovider(). A verb is the usual form; the exceptions are settled conventions, namely static factories (fromFile()), conversions (toArray()), interface methods (jsonSerialize()) and fluent interfaces whose names echo the domain rather than an action, as a query builder echoes SQL clauses - PascalCase for classes and class constants/enums
- camelCase for methods and properties
- Boolean query methods are
is*/has*/can*; a boolean property is named by the state itself ($active), never$isActive - Never use prefixes/suffixes like
Abstract,Interface, orI- the type system already distinguishes them
Method Order
- Place a new method deliberately - the order of methods is the outline a reader gets, saying which parts are primary and which are derived. The three rules below are in order of precedence: when they disagree, the earlier one wins
- Keep a method with those covering the same subject, and never break up a group that belongs together, not even with a method on that same subject - it goes before the whole group or after it
- Put the general before the special: a variant of an existing method goes right after it, never before, so the reader meets the plain form first and the special case second. A method serving one narrow use case follows the general ones rather than sitting among them
- A helper goes after the method that needs it, after all of them when it serves several. Where exactly is settled by the two rules above and by what surrounds it: it may follow immediately, it may sit after the whole group, it may close the class. Visibility does not decide the order - a private helper is not moved to the end of the class for being private
- Leave existing methods where they are - reordering them buries the real change in the diff
Formatting
- Use TABs for indentation everywhere (PHP, JS, HTML, CSS/SCSS, NEON, Latte, ...)
- PHP follows the Nette coding standard (PER Coding Style) with these modifications:
- No space before parentheses in arrow functions:
fn($a) => $b - No blank lines required between different
useimport types - When parameters span multiple lines, return type and opening brace go on separate lines:
- No space before parentheses in arrow functions:
// Short params - standard single-line
public function getItems(string $type): array
{
// method body
}
// Multi-line params - return type and brace on separate lines
public function example(
string $param,
array $options,
): string
{
// method body
}
Global Functio
Install php-coding-standards in Claude Code & Claude Desktop
Sign up to install this skill
Create a free account to reveal the install command and save the skill to your library.
- Reveal the one-line install command
- Save skills to your synced library
- Get notified when skills update
Allowed tools
Tools this skill is permitted to call.
No restriction — this skill can use any tool.
FAQ
What does the php-coding-standards skill do?
Invoke BEFORE writing or modifying any PHP code. Provides coding standards and naming conventions for Nette repos: TABs, single quotes, strict_types, PER Coding Style modifications, use statement ordering. Use this whenever creating, modifying, or refactoring any PHP code - even small bug fixes or one-line changes.
How do I install the php-coding-standards skill?
Copy the skill folder into ~/.claude/skills (the Claude Code tab above does this in one command), or install it as a plugin.
Does the php-coding-standards skill run scripts?
No, this skill is instructions only (SKILL.md) with no executable scripts.
Related skills
doc-coauthoring
Guide users through a structured workflow for co-authoring documentation. Use when user wants to write documentation, proposals, technical specs, decision…
by Anthropicacademy-guide
Stop and check this skill before finishing any reply to a question about how to use Claude or a Claude product — it recommends matching courses, tutorials…
by Anthropicinternal-comms
A set of resources to help me write all kinds of internal communications, using the formats that my company likes to use. Claude should use this skill…
by Anthropicskill-development
This skill should be used when the user wants to "create a skill", "add a skill to plugin", "write a new skill", "improve skill description", "organize skill…
by Anthropic