Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Susina Coding Standard

Test Installation

Susina Coding Standard library is a set of php-cs-fixer rules for Susina project repository. It's based on PSR1 and PSR12, with the following differences:

  • always use declare(strict_types=1) and put it at the beginning of the file, one space after <?php statement. I.e.: <?php declare(strict_types=1);
  • always use short array syntax
  • always put one space around string concatenation operator: 'string1' . 'string2'

Installation

Run

$ composer require --dev susina/coding-standard

Configuration

Create a .php-cs-fixer.php file in the root of your project:

<?php declare(strict_types=1);

$config = new Susina\CodingStandard\Config();
$config->getFinder()
    ->in(__DIR__ . '/src')
    ->in(__DIR__ . '/tests')
    ->excludes(['fixtures'])
;

return $config;

See php-cs-fixer documentation for further information.

Composer Scripts

Add to your composer.json file the following lines:

 "scripts" : {
     "cs" : "php-cs-fixer fix -v --diff --dry-run",
     "cs-fix" : "php-cs-fixer fix -v --diff"
 }

Now you can check your code style by running:

composer cs

and you can fix it by:

composer cs-fix

Git

We suggest adding .php-cs-fixer.cache to .gitignore:

vendor/
.php-cs-fixer.cache

Travis

You can configure Travis to cache the .php-cs-fixer.cache file. Update your .travis.yml:

cache:
  directories:
    - $HOME/.php-cs-fixer

Then run php-cs-fixer in the script section:

script:
  - composer cs

Github Actions

You can configure Github actions to cache .php-cs-fixer.cache file. In your workflow, into the Cache configuration step, simply add ~/.php-cs-fixer.cache under the path key:

- name: Cache multiple paths
  uses: actions/cache@v2
  with:
     path: |
        ~/.php-cs-fixer.cache
     key: your-awesome-cache-key

License

This package is licensed under the Apache2 License. For full copyright information, please see LICENSE file, in this repository.

About

php-cs-fixer rules, based on PSR-1 and PSR-12

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages