PHP-CS-Fixer 改版了,容许我布个道,发(抄)个配置
PHP-CS-Fixer,能帮你修正代码规范。
改版后,旧项目的 .php_cs 改为 .php-cs-fixer.php
替换如下:
<?php
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
$rules = [
'@PHP80Migration' => true,
'not_operator_with_successor_space' => true, // ! 运算带有空格,比如「if (! $var)」
'ordered_imports' => [ // use 排序
'sort_algorithm' => 'alpha',
],
'single_line_comment_spacing' => true, // 单行注释,「//」后添加空格
'class_attributes_separation' => [
'elements' => [
'const' => 'one',
'method' => 'one',
'property' => 'one',
],
],
];
$finder = Finder::create()
->in([
__DIR__.'/app',
__DIR__.'/config',
__DIR__.'/database',
__DIR__.'/resources',
__DIR__.'/routes',
__DIR__.'/tests',
])
->name('*.php')
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
return (new Config())
->setFinder($finder)
->setRules($rules)
->setRiskyAllowed(true)
->setUsingCache(true);
本作品采用《CC 协议》,转载必须注明作者和本文链接
第一次认识到这个插件,学习一下
可以使用内置的 ruleset
虽然没看懂,赞一下再说
里面的规则都是啥意思?从哪里才能看到这些配置项