pixelfederation / coding-standards
Standardized PHPCS sniffs for backend developers.
Installs: 66 573
Dependents: 3
Suggesters: 0
Security: 0
Stars: 1
Watchers: 7
Forks: 0
Open Issues: 1
Language:Dockerfile
Requires
- php: ^8.1
- phpcompatibility/php-compatibility: ^9.3.5
- slevomat/coding-standard: ^8.16.0
- squizlabs/php_codesniffer: ^3.7.2
Requires (Dev)
- ergebnis/composer-normalize: ^2.45
- dev-master
- 4.1.1
- 4.1.0
- 4.0.0
- 3.0.0
- 2.1.0
- 2.0.0
- 1.0.5
- 1.0.4
- 1.0.3
- 1.0.2
- 1.0.1
- 1.0.0
- dev-feat/update-deps-php84
- dev-dependabot/composer/slevomat/coding-standard-8.16.0
- dev-dependabot/composer/squizlabs/php_codesniffer-3.11.3
- dev-dependabot/composer/slevomat/coding-standard-8.15.0
- dev-feat/mutiline-constructor
This package is auto-updated.
Last update: 2025-02-25 09:06:08 UTC
README
This package provides PHPCS rule set for coding standards in Pixel Federation. It should be included into each project maintained by Pixel Federation that uses PHP Code Sniffer PHPCS.
Migration from v4 to v5
Generic ruleset was removed. Now there are only rulesets for specific PHP versions.
Replace (in your ruleset) reference to file
vendor/pixelfederation/coding-standards/phpcs.ruleset.xml
with
vendor/pixelfederation/coding-standards/phpcs.ruleset.84.xml
for PHP 8.4.
How to use
Install composer dependencies
composer require --dev pixelfederation/coding-standards:^5.0
Supported versions
For each php version there are 2 versions of the ruleset. One for DDD projects and one for Non-DDD projects.
For example for PHP 8.4:
vendor/pixelfederation/coding-standards/phpcs.ruleset.84.xml
OR
vendor/pixelfederation/coding-standards/phpcs.ruleset.84.non-ddd.xml
Ruleset creation
Create a file named phpcs.ruleset.xml
in the root folder of your project with the following content:
<?xml version="1.0"?> <ruleset name="PixelFederation"> <description>PixelFederation rule set.</description> <exclude-pattern>tests/</exclude-pattern> <rule ref="vendor/pixelfederation/coding-standards/phpcs.ruleset.84.xml"> <!-- Insert version for your php version --> <!-- You can exclude some rules here --> <exclude name="SlevomatCodingStandard.Files.FunctionLength"/> </rule> </ruleset>
Running checks
In your project directory run this command:
vendor/bin/phpcs --standard=phpcs.ruleset.xml src
Automatically fixing errors
In your project directory run this command:
vendor/bin/phpcbf --standard=phpcs.ruleset.xml src
Additional links
Sniffs documentation for slevomat coding standards are here: https://github.com/slevomat/coding-standard