brick / coding-standard
Coding standard tools and configurations used in Brick organization.
Fund package maintenance!
BenMorel
Requires
- php: >=8.1
- slevomat/coding-standard: 8.20.0
- squizlabs/php_codesniffer: 3.13.2
- symplify/easy-coding-standard: 12.5.24
README
Coding standard for Brick libraries.
Overview
This coding standard is used in Brick libraries, but can also be used in your own projects.
It is based on PSR-12 and uses Easy Coding Standard with rules cherry-picked from PHP-CS-Fixer, PHP_CodeSniffer, and the Slevomat coding standard.
Release process
This project is released with sequential version numbers: v1
, v2
, etc.
Each new version should be considered as breaking, as it may update dependency versions, add new rules, or modify existing ones.
Usage
Use locally
To use brick/coding-standard
locally, install it with Composer:
composer require --dev brick/coding-standard
Then create an ecs.php
file in the root of your project with the following content:
<?php declare(strict_types=1); use Symplify\EasyCodingStandard\Config\ECSConfig; return static function (ECSConfig $ecsConfig): void { $ecsConfig->import(__DIR__ . '/vendor/brick/coding-standard/ecs.php'); $ecsConfig->paths( [ __DIR__ . '/src', __DIR__ . '/tests', __FILE__, ], ); };
You can then run Easy Coding Standard with:
vendor/bin/ecs
or, to fix coding standard violations automatically:
vendor/bin/ecs --fix
If you wish to avoid conflicts with your project dependencies, you may also install ECS in a tools
directory with its
own composer.json
instead. Here is how your directory may look like:
tools/
└── ecs/
├── composer.json
├── composer.lock
└── ecs.php
└── vendor/
└── ...
Use in GitHub Actions
You can integrate brick/coding-standard
in your GitHub Actions workflow as follows:
name: Coding Standard on: pull_request: push: jobs: coding-standard: name: Coding Standard uses: brick/coding-standard/.github/workflows/coding-standard.yml@v1
By default, this workflow will run on PHP 8.1. You can change the PHP version by adding:
with: php-version: 8.2
Only versions >= 8.1
are supported.
Other options available are:
composer-options
working-directory
config-file