- PHP 8.2+,
declare(strict_types=1), typed properties, union types, enums, readonly classes. - Formatting: PSR-12 via a fixer (e.g., PHP_CodeSniffer/phpcbf or php-cs-fixer). Static analysis: a strict analyzer (e.g., PHPStan at max level or Psalm).
- Testing: PHPUnit with
@dataProvider, 80%+ coverage. - Error handling: specific exceptions extending
RuntimeException, constructor promotion for value objects. - First-class callable syntax (
$fn = strlen(...)) for callbacks. Arrow functions (fn() =>) for simple closures. - Dependencies: Composer with
composer.lockcommitted,^version constraints.composer auditin CI. - Security: require
roave/security-advisoriesas dev dependency to block vulnerable packages. - PSR-4 autoloading exclusively — no
require/includefor classes. - Intersection types for strict parameter contracts. Named arguments for readability.
- Anti-patterns:
@suppression,eval(), dynamic property access,extract().
PHP Conventions
PHP code conventions covering PHP 8.2+ strict types, PSR-12 formatting, PHPStan/Psalm static analysis, PHPUnit, Composer dependency management, PSR-4 autoloading, and security. Load when writing or reviewing PHP code.
PHP Conventions by goldziher · c79673e
npx skillmds@latest add goldziher/php-conventions File contents
---name: php-conventionsdescription: PHP code conventions covering PHP 8.2+ strict types, PSR-12 formatting, PHPStan/Psalm static analysis, PHPUnit, Composer dependency management, PSR-4 autoloading, and security. Load when writing or reviewing PHP code.---- PHP 8.2+, `declare(strict_types=1)`, typed properties, union types, enums, readonly classes.- Formatting: PSR-12 via a fixer (e.g., PHP_CodeSniffer/phpcbf or php-cs-fixer). Static analysis: a strict analyzer (e.g., PHPStan at max level or Psalm).- Testing: PHPUnit with `@dataProvider`, 80%+ coverage.- Error handling: specific exceptions extending `RuntimeException`, constructor promotion for value objects.- First-class callable syntax (`$fn = strlen(...)`) for callbacks. Arrow functions (`fn() =>`) for simple closures.- Dependencies: Composer with `composer.lock` committed, `^` version constraints. `composer audit` in CI.- Security: require `roave/security-advisories` as dev dependency to block vulnerable packages.- PSR-4 autoloading exclusively — no `require`/`include` for classes.- Intersection types for strict parameter contracts. Named arguments for readability.- Anti-patterns: `@` suppression, `eval()`, dynamic property access, `extract()`.
goldziher/ai-rulez/tree/main/internal/builtins/languages/php/skills/php-conventions commit c79673e3ad
Frequently asked questions
Run npx skillmds@latest add goldziher/php-conventions in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
PHP code conventions covering PHP 8.2+ strict types, PSR-12 formatting, PHPStan/Psalm static analysis, PHPUnit, Composer dependency management, PSR-4 autoloading, and security. Load when writing or reviewing PHP code. It is listed under Security on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
goldziher (@goldziher) published this skill. Their other Agent Skills are listed on their SkillMD profile.