plugins/nette-dev/skills/php-coding-standards/SKILL.md
--- name: php-coding-standards description: Invoke BEFORE writing or modifying any PHP code. Provides coding standards and naming conventions for Nette repos: TABs, single quotes, strict_types, PSR-12 modifications, use statement ordering. Use this whenever creating, modifying, or refactoring any PHP code - even small bug fixes or one-line changes. --- ## PHP Coding Standards ### Using nette/coding-standard Install globally using `/php-fixer:install-php-fixer`. After installation, PHP files a
npx skillsauth add nette/claude-code plugins/nette-dev/skills/php-coding-standardsInstall 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.
Install globally using /php-fixer:install-php-fixer. After installation, PHP files are automatically fixed when edited - see the php-auto-fixer skill for editing workflow rules (especially use statement ordering).
declare(strict_types=1)@mkdir($dir); // @ - directory may already exist// == accept nullexceptions.php file, and multiple enums into enums.phpIO, DB), PascalCase/camelCase for longer ones (Http, Xml)ArrayIterator)Abstract, Interface, or I - the type system already distinguishes themfn($a) => $buse import types// 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
}
count($arr) not \count($arr)use function at the file beginning:
use Nette;
use function count, is_array, is_scalar, sprintf;
use const PHP_OS_FAMILY;
if (is_array($response['data'] ?? null)) instead of if (isset($response['data']) && is_array($response['data']))is_a($obj, $class, allow_string: true)), but not when the method name makes it clear (e.g., setReadonly(true))Foo\Network next to Foo\Networks\*, not inside it) - this keeps the interface discoverable at the package levelarray. Arrays lose type information; typed objects let PHPStan catch errors at analysis time and give full IDE support.tools
CRITICAL: Read BEFORE writing or modifying any PHP file. A PostToolUse hook automatically runs nette/coding-standard (ECS) on every PHP file after each Edit or Write. The fixer removes unused `use` statements - so never add `use` statements in a separate edit before the code that references them. Always include `use` imports in the same edit as the referencing code, or add the code first then `use` statements. This skill should be used whenever creating new PHP files, editing existing PHP code, adding methods, refactoring, or fixing bugs in PHP - even for small one-line changes.
development
Install nette/coding-standard globally for PHP code style checking
tools
Invoke when fetching web pages from localhost, debugging PHP errors, or interpreting Tracy output (BlueScreen, Tracy Bar, dump). Read BEFORE running curl or Chrome to any local development PHP URL – with Tracy >= 2.12 and a detected agent, Tracy mirrors BlueScreen, Tracy Bar and dumps as markdown into the JS console for easy machine reading. For Chrome MCP, call list_console_messages() to read Tracy output. Essential when: 500 error, blank page, PHP exception, slow page, N+1 queries, or inspecting variables with dump().
tools
Provides Nette Utils helper classes. Use when working with Arrays, Strings, Image, Finder, FileSystem, Json, Validators, DateTime, Html element builder, Random, Callback, Type, or SmartObject from nette/utils. Do NOT use for Nette Schema, Nette Forms, Nette Database, Latte filters, or DI configuration.