2017 © Pedro PelĂĄez
 

library additional-php-cs-fixers

Some additional custom fixers for php-cs-fixer.

image

novius/additional-php-cs-fixers

Some additional custom fixers for php-cs-fixer.

  • Thursday, May 11, 2017
  • by novius
  • Repository
  • 4 Watchers
  • 0 Stars
  • 1,398 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 13 % Grown

The README.md

This library adds some custom fixers for php-cs-fixer (v2)., (*1)

Installation

Add this package to your composer.json:, (*2)

{
    "require-dev": {
        "novius/additional-php-cs-fixers": "~1.0.0"
    },
}

Modify your .php_cs:, (*3)

  • Include the composer autoload:
include 'vendor/autoload.php';
  • Register the custom fixers:
return PhpCsFixer\Config::create()
    //...
    ->registerCustomFixers(SebC\AdditionalPhpCsFixers\Helper::getCustomFixers())
  • Use the new rules as you wish:
$rules = [
    // ...
    'SebCAdditionalPhpCsFixers/disallow_unaliased_classes' => [
        'replace_namespaces' => [
            'Fuel\Core' => '',
            'Illuminate\Support\Facades' => '',
        ],
    ],
];

disallow_unaliased_classes rule:

This prevents any use of some specific namespace, and encourages to replace it with another., (*4)

This is mainly useful/designed to force the use of aliased classes in some frameworks like Laravel or FuelPHP., (*5)

As example, with the following rules configuration: - 'Fuel\Core' => '', will trigger an error everytime a class such as Fuel\Core\Config is directly called, and will suggest to replace it with Config - 'Illuminate\Support\Facades' => '', will prevent a call like Illuminate\Support\Facades\Validator and replace it with Validator - 'Some\Evil\Stuff' => 'OtherStuff', will replace Some\Evil\Stuff\Foo::myFunction() with OtherStuff\Foo::myFunction(), (*6)

This also works with used namespaces., (*7)

TODO

Unit tests, (*8)

The Versions

11/05 2017

dev-master

9999999-dev

Some additional custom fixers for php-cs-fixer.

  Sources   Download

The Requires

  • php >=5.6

 

The Development Requires

by Sébastien Caparros

11/05 2017

1.0.1

1.0.1.0

Some additional custom fixers for php-cs-fixer.

  Sources   Download

The Requires

  • php >=5.6

 

The Development Requires

by Sébastien Caparros

03/05 2017

dev-feature/phpcs-travis

dev-feature/phpcs-travis

Some additional custom fixers for php-cs-fixer.

  Sources   Download

The Requires

  • php >=5.6

 

The Development Requires

by Sébastien Caparros

03/05 2017

1.0.0

1.0.0.0

Some additional custom fixers for php-cs-fixer.

  Sources   Download

The Requires

  • php >=5.6

 

The Development Requires

by Sébastien Caparros