novius / additional-php-cs-fixers
Some additional custom fixers for php-cs-fixer.
Installs: 2 010
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
pkg:composer/novius/additional-php-cs-fixers
Requires
- php: >=5.6
Requires (Dev)
- friendsofphp/php-cs-fixer: ~2.3.1
This package is auto-updated.
Last update: 2025-10-26 13:54:20 UTC
README
This library adds some custom fixers for php-cs-fixer (v2).
Installation
Add this package to your composer.json:
{
"require-dev": {
"novius/additional-php-cs-fixers": "~1.0.0"
},
}
Modify your .php_cs:
- 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.
This is mainly useful/designed to force the use of aliased classes in some frameworks like Laravel or FuelPHP.
As example, with the following rules configuration:
'Fuel\Core' => '',will trigger an error everytime a class such asFuel\Core\Configis directly called, and will suggest to replace it withConfig'Illuminate\Support\Facades' => '',will prevent a call likeIlluminate\Support\Facades\Validatorand replace it withValidator'Some\Evil\Stuff' => 'OtherStuff',will replaceSome\Evil\Stuff\Foo::myFunction()withOtherStuff\Foo::myFunction()
This also works with used namespaces.
TODO
Unit tests