pekral/phpcs-rules
| Install | |
|---|---|
composer require pekral/phpcs-rules |
|
| Latest Version: | 0.5 |
| PHP: | ^8.5 |
| License: | MIT |
| Last Updated: | Nov 12, 2026 |
| Links: | GitHub · Packagist |
phpcs-rules
A ready-made ruleset for PHP_CodeSniffer (PHPCS) built on the Slevomat Coding Standard. It enables around 160 rules for arrays, classes, comments, control structures, namespaces, type hints, whitespace and more, so PHP projects get one consistent code style from a single ruleset.xml.
Requirements
- PHP 8.4 or newer. The latest tagged release, 0.5.0, still requires PHP 8.5; PHP 8.4 support returns with the next release (see CHANGELOG).
- Composer.
slevomat/coding-standard and dealerdirect/phpcodesniffer-composer-installer are installed with the package.
Installation
composer require --dev pekral/phpcs-rules
Configuration
No configuration is needed: pass the shipped ruleset to PHPCS with --standard. To add or override rules, reference it from a ruleset.xml in your project and run PHPCS with --standard=ruleset.xml:
<?xml version="1.0"?>
<ruleset name="Custom PHPCS Rules">
<rule ref="vendor/pekral/phpcs-rules/ruleset.xml"/>
<!-- Your custom rules here -->
</ruleset>
Quick start
Check a directory:
vendor/bin/phpcs --standard=vendor/pekral/phpcs-rules/ruleset.xml src/
Fix what can be fixed automatically:
vendor/bin/phpcbf --standard=vendor/pekral/phpcs-rules/ruleset.xml src/
[!WARNING]
phpcbfrewrites files in place. Commit or back up your changes before running it.
The ruleset checks only .php files and turns some rules off for certain paths, for example tests/* for ClassLength, FileLength and StaticClosure.
Documentation
- Rules: every rule the ruleset enables, with key settings and path exclusions.
Testing
composer test
composer check
composer test runs PHPUnit; composer check runs PHPCS with this ruleset on Examples/, src/ and tests/. CI also runs PHPStan, Rector in dry-run mode and composer check-unused-sniffs on PHP 8.4 and 8.5.
Changelog
See CHANGELOG.
License
The MIT License (MIT). See LICENSE.
Related Packages
Keep your PHP code clean and maintainable by enforcing quality rules based on me...
Static analysis for Filament projects - detect deprecated patterns and code issu...
Static analysis for the debt AI coding agents leave behind, on any PHP project:...
Version History
| Version | Released | PHP | License |
|---|---|---|---|
| 0.5 | ^8.5 | MIT | |
| 0.4.8 | ^8.4 | MIT | |
| 0.4.7 | ^8.4 | MIT | |
| 0.4.6 | ^8.4| | MIT | |
| 0.4.5 | ^8.4 | MIT | |
| 0.4.4 | ^8.4| | MIT | |
| 0.4.3 | ^8.4| | MIT | |
| 0.4.2 | ^8.4 | MIT | |
| 0.4.1 | ^8.4 | MIT | |
| 0.4 | ^8.4 | MIT | |
| 0.3 | ^8.3 | MIT | |
| 0.2 | ^8.1 | MIT | |
| 0.1 | ^8.1 | MIT |