如何在php-cs-fixer中使用其他文件扩展名,例如cakephp模板.ctp文件?
我试过这段代码:
<?php
$finder = PhpCsFixer\Finder::create()
->notPath('bootstrap/cache')
->notPath('storage')
->notPath('vendor')
->in(__DIR__)
->name('*.php') // <===== *.ctp
->notName('*.blade.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
;
return PhpCsFixer\Config::create()
->setRules(array(
'@Symfony' => true,
'binary_operator_spaces' => ['align_double_arrow' => false],
'array_syntax' => ['syntax' => 'short'],
'linebreak_after_opening_tag' => true,
'not_operator_with_successor_space' => true,
'ordered_imports' => true,
'phpdoc_order' => true,
))
->setFinder($finder)
;发布于 2018-06-18 19:32:11
问题是,使用运行PHP CS Fixer的原始方法,您在配置文件中配置了一次路径查找器,然后将路径也作为CLI参数传递。因此,您在配置中完全定义了finder,但后来被CLI参数覆盖,您还会收到一条消息:
Paths from configuration file have been overridden by paths provided as command arguments.解决方案是:-仅在配置文件中提供路径-仅提供路径作为CLI参数-在两个位置都提供路径(例如,在配置plugins中,而作为CLI参数plugins/subdir (因为传递完全相同的值实际上没有意义...),但也提供--path-mode=intersection参数,以不覆盖路径,但采用路径的公共部分(一个在配置中,一个作为CLI参数)
发布于 2019-09-27 16:27:49
非常重要的一点是,不要在终端命令示例中使用路径参数:
php-cs-fixer fix test/global.phpcs修复程序使用来自命令参数的路径,而不是查找器
只需运行
php-cs-fixer fix 这很简单,但你可以通过疏忽跳过它。
https://stackoverflow.com/questions/48967493
复制相似问题