whatwedo / php-coding-standard
Default PHP coding standard at whatwedo
Installs: 19 997
Dependents: 11
Suggesters: 0
Security: 0
Stars: 2
Watchers: 11
Forks: 1
Open Issues: 2
Requires
- php: >=7.4
- kubawerlos/php-cs-fixer-custom-fixers: ^3.0
- slevomat/coding-standard: ^8.5
- symplify/easy-coding-standard: ^11.1
This package is auto-updated.
Last update: 2024-03-30 00:25:36 UTC
README
PhpCodingStandard
This project is a set of coding standard rules, which we are using at whatwedo. It's heavily based on Simplify/EasyCodingStandard.
Installation
We suggest to use Composer to install this project:
composer require whatwedo/php-coding-standard
Usage
Without custom configuration
You can run the checks without project specific configuration using one of following commands:
vendor/bin/ecs check SRC_DIRECTORY --config vendor/whatwedo/php-coding-standard/config/whatwedo-symfony.php # Symfony projects
vendor/bin/ecs check SRC_DIRECTORY --config vendor/whatwedo/php-coding-standard/config/whatwedo-wordpress.php # WordPress projects
vendor/bin/ecs check SRC_DIRECTORY --config vendor/whatwedo/php-coding-standard/config/whatwedo-common.php # Common PHP projects
With custom configuration
If you want to add additional checkers or exclude files, you have to create an ecs.php
file in your own project root directory.
<?php declare(strict_types=1); use Symplify\EasyCodingStandard\Config\ECSConfig; return static function (ECSConfig $ecsConfig): void { /* // Remove rules with $ecsConfig->skip() $ecsConfig->skip([ SlevomatCodingStandard\Sniffs\Variables\UnusedVariableSniff::class => null, // Explicitly remove some rules in a specific files PhpCsFixer\Fixer\FunctionNotation\MethodArgumentSpaceFixer::class => [ __DIR__ . '/PATH/FILE.php' ], ]); */ // This need to come last $ecsConfig->sets([__DIR__ . '/vendor/whatwedo/php-coding-standard/config/whatwedo-common.php']); };
Then run the following command:
vendor/bin/ecs check SRC_DIRECTORY
To fix certain issues automatically add --fix
add the end
For other configuration options, check out Simplify/EasyCodingStandard.
Dependencies
- PHP >=7.4
- Simplify/EasyCodingStandard
- kubawerlos/php-cs-fixer-custom-fixers
- slevomat/coding-standard
License
This bundle is under the MIT license. See the complete license in the bundle: LICENSE