Documentation
Coding standard
All PHP code in phppdf projects is checked with PHP_CodeSniffer using the shared phppdf/coding-standard ruleset.
Installing
composer require --dev phppdf/coding-standard
Running
vendor/bin/phpcs --standard=PhpPdf src tests
Many projects expose this as a Composer script, e.g. composer cs.
What it checks
The ruleset builds on PSR-12 and adds a set of Slevomat Coding Standard sniffs, including:
- Trailing commas in arrays, function calls, and closure
uselists. - A consistent class member order (
ClassStructure). - Required and correctly-spaced parameter and return type hints.
- Alphabetically sorted, fully-qualified
usestatements with no unused or redundant aliases. - Consistent spacing around
usedeclarations, namespaces, and doc comments.
Requirements
PHP 8.4+ is required, matching the minimum PHP version supported by phppdf projects.