2017 © Pedro PelĂĄez
 

library php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

image

localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  • Saturday, July 7, 2018
  • by localheinz
  • Repository
  • 2 Watchers
  • 9 Stars
  • 6,600 Installations
  • PHP
  • 16 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 49 Versions
  • 41 % Grown

The README.md

:exclamation: Abandoned!

Use ergebnis/php-cs-fixer-config instead., (*1)

php-cs-fixer-config

CI Status codecov Latest Stable Version Total Downloads, (*2)

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer., (*3)

Installation

Run, (*4)

$ composer require --dev localheinz/php-cs-fixer-config

Usage

Configuration

Pick one of the rule sets:, (*5)

  • Localheinz\PhpCsFixer\RuleSet\Php71
  • Localheinz\PhpCsFixer\RuleSet\Php73

Create a configuration file .php_cs in the root of your project:, (*6)

<?php

use Localheinz\PhpCsFixer\Config;

$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71());

$config->getFinder()->in(__DIR__);
$config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php_cs.cache');

return $config;

Git

All configuration examples use the caching feature, and if you want to use it as well, you should add the cache directory to .gitignore:, (*7)

+ /.build/
 /vendor/

:bulb: Personally, I prefer to use a .build directory for storing build artifacts., (*8)

Configuration with header

:bulb: Optionally specify a header:, (*9)

 <?php

 use Localheinz\PhpCsFixer\Config;

+$header = <<<EOF
+Copyright (c) 2017 Andreas Möller
+
+For the full copyright and license information, please view
+the LICENSE file that was distributed with this source code.
+
+@see https://github.com/localheinz/php-cs-fixer-config
+EOF;

-$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71());
+$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71($header));

 $config->getFinder()->in(__DIR__);
 $config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php_cs.cache');

 return $config;

This will enable and configure the HeaderCommentFixer, so that file headers will be added to PHP files, for example:, (*10)

<?php

/**
 * Copyright (c) 2017 Andreas Möller
 *
 * For the full copyright and license information, please view
 * the LICENSE file that was distributed with this source code.
 *
 * @see https://github.com/localheinz/php-cs-fixer-config
 */

Configuration with override rules

:bulb: Optionally override rules from a rule set by passing in an array of rules to be merged in:, (*11)

 <?php

 use Localheinz\PhpCsFixer\Config;

-$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71());
+$config = Config\Factory::fromRuleSet(new Config\RuleSet\Php71(), [
+    'mb_str_functions' => false,
+    'strict_comparison' => false,
+]);

 $config->getFinder()->in(__DIR__);
 $config->setCacheFile(__DIR__ . '/.build/php-cs-fixer/php_cs.cache');

 return $config;

Makefile

If you like Makefiles, create a Makefile with a coding-standards target:, (*12)

+.PHONY: coding-standards
+coding-standards: vendor
+    mkdir -p .build/php-cs-fixer
+    vendor/bin/php-cs-fixer fix --config=.php_cs --diff --verbose

 vendor: composer.json composer.lock
     composer validate
     composer install

Run, (*13)

$ make coding-standards

to automatically fix coding standard violations., (*14)

Composer script

If you like composer scripts, add a coding-standards script to composer.json:, (*15)

 {
   "name": "foo/bar",
   "require": {
     "php": "^7.2",
   },
   "require-dev": {
     "friendsofphp/php-cs-fixer": "~2.16.0"
+  },
+  "scripts": {
+    "coding-standards": [
+      "mkdir -p .build/php-cs-fixer",
+      "php-cs-fixer fix --diff --diff-format=udiff --verbose"
+    ]
   }
 }

Run, (*16)

$ composer coding-standards

to automatically fix coding standard violations., (*17)

GitHub Actions

If you like GitHub Actions, add a coding-standards job to your workflow:, (*18)

 on:
   pull_request:
   push:
     branches:
       - master
     tags:
       - "**"

 name: "Continuous Integration"

 jobs:
+  coding-standards:
+    name: "Coding Standards"
+
+    runs-on: ubuntu-latest
+
+    steps:
+      - name: "Checkout"
+        uses: actions/checkout@v1.1.0
+
+      - name: "Disable Xdebug"
+        run: php7.2 --ini | grep xdebug | sed 's/,$//' | xargs sudo rm
+
+      - name: "Cache dependencies installed with composer"
+        uses: actions/cache@v1.0.2
+        with:
+          path: ~/.composer/cache
+          key: php7.2-composer-locked-${{ hashFiles('**/composer.lock') }}
+          restore-keys: |
+            php7.2-composer-locked-
+
+      - name: "Install locked dependencies with composer"
+        run: php7.2 $(which composer) install --no-interaction --no-progress --no-suggest
+
+      - name: "Create cache directory for friendsofphp/php-cs-fixer"
+        run: mkdir -p .build/php-cs-fixer
+
+      - name: "Cache cache directory for friendsofphp/php-cs-fixer"
+        uses: actions/cache@v1.0.2
+        with:
+          path: ~/.build/php-cs-fixer
+          key: php7.2-php-cs-fixer-${{ hashFiles('**/composer.lock') }}
+          restore-keys: |
+            php7.2-php-cs-fixer-
+
+      - name: "Run friendsofphp/php-cs-fixer"
+        run: php7.2 vendor/bin/php-cs-fixer fix --config=.php_cs --diff --diff-format=udiff --dry-run --verbose

Travis

If you like Travis CI, add a coding-standards stage to your jobs:, (*19)

 language: php

 cache:
   directories:
     - $HOME/.composer/cache
+    - .build/php-cs-fixer

 jobs:
   include:
+    - stage: "Coding Standards"
+
+      php: 7.2
+
+      install:
+        - composer install --no-interaction --no-progress --no-suggest
+
+      before_script:
+        - mkdir -p .build/php-cs-fixer
+
+      script:
+        - vendor/bin/php-cs-fixer fix --config=.php_cs --diff --dry-run --verbose

Changelog

Please have a look at CHANGELOG.md., (*20)

Contributing

Please have a look at CONTRIBUTING.md., (*21)

Code of Conduct

Please have a look at CODE_OF_CONDUCT.md., (*22)

License

This package is licensed using the MIT License., (*23)

Credits

This project is inspired by refinery29/php-cs-fixer-config, which I created and maintained from August 7, 2015 until May 29, 2017, while working for Refinery29, Inc., (*24)

The Versions

07/07 2018

dev-master

9999999-dev https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

07/07 2018

1.14.1

1.14.1.0 https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

07/07 2018

dev-fix/php-cs-fixer

dev-fix/php-cs-fixer https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

03/06 2018

1.14.0

1.14.0.0 https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

21/03 2018

1.13.1

1.13.1.0 https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

1.13.0

1.13.0.0 https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

dev-feature/php-unit-set-up-tear-down-visibility

dev-feature/php-unit-set-up-tear-down-visibility https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

dev-feature/string-line-ending

dev-feature/string-line-ending https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

dev-feature/standardize-increment

dev-feature/standardize-increment https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

dev-feature/php-unit-ordered-covers

dev-feature/php-unit-ordered-covers https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

dev-feature/no-alternative-syntax

dev-feature/no-alternative-syntax https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

dev-feature/fully-qualified-strict-types

dev-feature/fully-qualified-strict-types https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

dev-feature/date-time-immutable

dev-feature/date-time-immutable https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

dev-feature/comment-to-phpdoc

dev-feature/comment-to-phpdoc https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

dev-feature/array-indentation

dev-feature/array-indentation https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/03 2018

dev-feature/php-cs-fixer

dev-feature/php-cs-fixer https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

09/03 2018

1.12.3

1.12.3.0 https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

22/02 2018

1.12.2

1.12.2.0 https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

14/02 2018

1.12.1

1.12.1.0 https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

14/02 2018

1.12.0

1.12.0.0 https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

by Andreas Möller

27/01 2018

dev-fix/indent

dev-fix/indent https://github.com/localheinz/php-cs-fixer-config

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

10/01 2018

1.11.0

1.11.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

06/01 2018

1.10.0

1.10.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

04/01 2018

1.9.0

1.9.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

09/12 2017

1.8.0

1.8.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

27/11 2017

1.7.3

1.7.3.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

20/11 2017

1.7.2

1.7.2.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

13/11 2017

1.7.1

1.7.1.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

04/11 2017

1.7.0

1.7.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

02/11 2017

1.6.3

1.6.3.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

06/10 2017

dev-feature/php72

dev-feature/php72

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

06/10 2017

1.6.x-dev

1.6.9999999.9999999-dev

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

02/10 2017

1.6.2

1.6.2.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

29/09 2017

1.6.1

1.6.1.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

29/09 2017

dev-fix/optimize-autoloader

dev-fix/optimize-autoloader

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

29/09 2017

1.6.0

1.6.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

16/09 2017

dev-feature/test-util

dev-feature/test-util

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

12/09 2017

1.5.1

1.5.1.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

11/09 2017

1.5.0

1.5.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

28/08 2017

dev-foo

dev-foo

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

28/08 2017

1.4.0

1.4.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

31/07 2017

1.3.0

1.3.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

25/05 2017

1.2.1

1.2.1.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

22/04 2017

1.2.0

1.2.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

01/04 2017

1.1.0

1.1.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

29/03 2017

dev-feature/return-type-declaration

dev-feature/return-type-declaration

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

07/03 2017

1.0.2

1.0.2.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

06/03 2017

1.0.1

1.0.1.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller

06/03 2017

1.0.0

1.0.0.0

Provides a configuration factory and multiple rule sets for friendsofphp/php-cs-fixer.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Andreas Möller