php-conventions

Solid

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.

Code & Development 137 stars 13 forks Updated today MIT

Install

View on GitHub

Quality Score: 84/100

Stars 20%
71
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
49
Issue Health 10%
80
License 10%
100
Description 5%
100

Skill Content

- 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()`.

Details

Author
Goldziher
Repository
Goldziher/ai-rulez
Created
1 years ago
Last Updated
today
Language
Go
License
MIT

Similar Skills

Semantically similar based on skill content — not just same category