2017 © Pedro PelĂĄez
 

library php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

image

narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  • Tuesday, July 24, 2018
  • by dani33
  • Repository
  • 1 Watchers
  • 1 Stars
  • 18,076 Installations
  • PHP
  • 12 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 27 Versions
  • 5 % Grown

The README.md

Narrowspark php-cs-fixer Config

, (*1)

This repository provides a configuration for https://github.com/FriendsOfPHP/PHP-CS-Fixer, which we use to verify and enforce a single coding standard for PHP code within Narrowspark and Anolilab., (*2)

Installation

Via Composer, (*3)

``` bash $ composer require narrowspark/php-cs-fixer-config, (*4)


Usage ------------- Create a configuration file `.php_cs` in the root of your project: ```php <?php declare(strict_types=1); use Narrowspark\CS\Config\Config; $config = new Config(); $config->getFinder() ->files() ->in(__DIR__) ->exclude('.build') ->exclude('vendor') ->name('*.php') ->ignoreDotFiles(true) ->ignoreVCS(true); $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 add the cache directory to .gitignore:, (*5)

+ /.build/
 /vendor/

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

Configuration with header

:bulb: optionally specify a header:, (*7)

<?php
declare(strict_types=1);

use Narrowspark\CS\Config\Config;

+$header = <<<EOF
+Copyright (c) 2020 Narrowspark
+
+For the full copyright and license information, please view
+the LICENSE file that was distributed with this source code.
+EOF;

-$config = new Narrowspark\CS\Config\Config();
+$config = new Narrowspark\CS\Config\Config($header);

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

return $config;

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

Configuration with override rules

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

<?php
declare(strict_types=1);

use Narrowspark\CS\Config\Config;

- $config = new Config();
+ $config = new Config(null /* if you dont need a header */, [
    'mb_str_functions' => false,
    'strict_comparison' => false,
]);

$config->getFinder()
    ->files()
    ->in(__DIR__)
    ->exclude('.build')
    ->exclude('vendor')
    ->name('*.php')
    ->ignoreDotFiles(true)
    ->ignoreVCS(true);

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

return $config;

Composer

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

 {
   "name": "foo/bar",
   "require": {
     "php": "^7.3",
   },
   "require-dev": {
     "narrowspark/php-cs-fixer-config": "~1.0.0"
+  },
+  "scripts": {
+    "cs:check": [
+      "mkdir -p .build/php-cs-fixer",
+      "php-cs-fixer fix --diff --diff-format=udiff --verbose"
+    ]
   }
 }

Run, (*11)

$ composer cs:check

To automatically fix coding standard violations., (*12)

Travis

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

 language: php

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

 jobs:
   include:
+    - stage: "Coding Standards"
+
+      php: 7.3
+
+      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

GitHub Actions

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

 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.3 --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.3-composer-locked-${{ hashFiles('**/composer.lock') }}
+          restore-keys: |
+            php7.3-composer-locked-
+
+      - name: "Install locked dependencies with composer"
+        run: php7.3 $(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.3-php-cs-fixer-${{ hashFiles('**/composer.lock') }}
+          restore-keys: |
+            php7.3-php-cs-fixer-
+
+      - name: "Run friendsofphp/php-cs-fixer"
+        run: php7.3 vendor/bin/php-cs-fixer fix --config=.php_cs --diff --diff-format=udiff --dry-run --verbose

Testing

bash $ vendor/bin/phpunit, (*15)

Contributing

If you would like to help take a look at the list of issues and check our Contributing guild., (*16)

Note: please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms., (*17)

Credits

License

The Narrowspark http-emitter is open-sourced software licensed under the MIT license, (*18)

The Versions

24/07 2018

dev-master

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

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

24/07 2018

v3.0.3

3.0.3.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

27/06 2018

v3.0.2

3.0.2.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

04/06 2018

v3.0.1

3.0.1.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

27/05 2018

v3.0.0

3.0.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

27/11 2017

v2.1.0

2.1.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

01/09 2017

v2.0.4

2.0.4.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

19/07 2017

v2.0.3

2.0.3.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

19/07 2017

v2.0.2

2.0.2.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

19/07 2017

v2.0.1

2.0.1.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

18/07 2017

v2.0.0

2.0.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

18/12 2016

2.2.1

2.2.1.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

18/12 2016

dev-develop

dev-develop https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

18/12 2016

2.2.0

2.2.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

06/11 2016

2.1.0

2.1.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

17/08 2016

2.0.0

2.0.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

01/06 2016

v1.4.1

1.4.1.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

28/05 2016

v1.4.0

1.4.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for friendsofphp/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

27/05 2016

v1.3.0

1.3.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for fabpot/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

26/05 2016

v1.2.0

1.2.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for fabpot/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

06/01 2016

v1.1.5

1.1.5.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for fabpot/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

21/12 2015

v1.1.4

1.1.4.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for fabpot/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

21/12 2015

v1.1.3

1.1.3.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for fabpot/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

21/12 2015

v1.1.2

1.1.2.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for fabpot/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

21/12 2015

v1.1.1

1.1.1.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for fabpot/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

21/12 2015

v1.1.0

1.1.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for fabpot/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer

21/12 2015

v1.0.0

1.0.0.0 https://github.com/narrowspark/php-cs-fixer-config

Provides a configuration for fabpot/php-cs-fixer, used within Narrowspark.

  Sources   Download

MIT

The Requires

 

The Development Requires

config cs php-cs-fixer narrowspark cs-fixer