Skip to content

brick/coding-standard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Brick Coding Standard

Coding standard for Brick libraries.

Build Status Latest Stable Version Total Downloads License

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.2. You can change the PHP version by adding:

    with:
      php-version: 8.5

Only versions >= 8.2 are supported.

Other options available are:

  • composer-options
  • working-directory
  • config-file

About

Coding standard for Brick libraries.

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages