php cs fixer,如何运行 冒险规则?
php cs fixer, how to run risky rules?
您好,我是第一次使用 php-cs-fixer。我知道我们必须设置一个 .php_cs.dist 文件
这是我从 php-cs-fixer.
的 git 存储库中获得的示例文件
$finder = PhpCsFixer\Finder::create()
->exclude('somedir')
->in(__DIR__);
return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'full_opening_tag' => false,
))
->setFinder($finder);
当我运行在 CLI
上执行此命令时
php-cs-fixer fix --config=.php_cs.dist --allow-risky
据说我需要为 --allow-risky 提供选项,但在文档中没有提到如何设置 allow risky 选项帮助我 guys.The 越快越好。
我的问题
如何运行冒险规则?因为没有提到如何在 php-cs-fixer.
中使用 allow risky 规则
方法是->setRiskyAllowed(true)
。 Implementation code.
您的代码应如下所示:
$finder = PhpCsFixer\Finder::create()
->exclude('somedir')
->in(__DIR__);
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(array(
'@Symfony' => true,
'full_opening_tag' => false,
))
->setFinder($finder);
我同意这个方法有点隐蔽,我是在浏览源代码之前没有找到它的。
我们可以在命令行中启用允许风险选项,如下所示:
php-cs-fixer fix --config=.php_cs.dist --allow-risky=yes
您好,我是第一次使用 php-cs-fixer。我知道我们必须设置一个 .php_cs.dist 文件
这是我从 php-cs-fixer.
的 git 存储库中获得的示例文件$finder = PhpCsFixer\Finder::create()
->exclude('somedir')
->in(__DIR__);
return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'full_opening_tag' => false,
))
->setFinder($finder);
当我运行在 CLI
上执行此命令时php-cs-fixer fix --config=.php_cs.dist --allow-risky
据说我需要为 --allow-risky 提供选项,但在文档中没有提到如何设置 allow risky 选项帮助我 guys.The 越快越好。
我的问题 如何运行冒险规则?因为没有提到如何在 php-cs-fixer.
中使用 allow risky 规则方法是->setRiskyAllowed(true)
。 Implementation code.
您的代码应如下所示:
$finder = PhpCsFixer\Finder::create()
->exclude('somedir')
->in(__DIR__);
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setRules(array(
'@Symfony' => true,
'full_opening_tag' => false,
))
->setFinder($finder);
我同意这个方法有点隐蔽,我是在浏览源代码之前没有找到它的。
我们可以在命令行中启用允许风险选项,如下所示:
php-cs-fixer fix --config=.php_cs.dist --allow-risky=yes