joselc / php-cs-fixer-custom-fixers
为PHP编码标准修复器设置意见规则
v1.0.1
2022-08-30 12:28 UTC
Requires
- php: ^8.0
- ext-json: *
- friendsofphp/php-cs-fixer: ^3.0
Requires (Dev)
- phpstan/phpstan: ^1.8
- roave/security-advisories: dev-latest
- thecodingmachine/safe: ^2.0
Suggests
README
为php-cs-fixer设置意见规则。
如果使用thecodingmachine/safe,将自动添加Safe提供的导入规则。
安装
composer require --dev josecl/php-cs-fixer-custom-fixers
使用
在你的PHP编码标准修复器配置文件(通常是.php-cs-fixer.dist.php
)中,你应该使用Josecl\PhpCsFixerCustomFixers\CustomConfig
代替PhpCsFixer\Config
,它已经定义了规则集。
<?php use Josecl\PhpCsFixerCustomFixers\CustomConfig; $finder = Symfony\Component\Finder\Finder::create() ->in([ __DIR__ . '/app', __DIR__ . '/config', // etc... ]) ->name('*.php') ->notName('*.blade.php') ->ignoreDotFiles(true) ->ignoreVCS(true); return (new CustomConfig())->setFinder($finder);
你可以通过extraRules
参数自定义规则集。
return (new CustomConfig(extraRules: [ 'yoda_style' => ['equal' => true], // ... ]))->setFinder($finder);