我通过运行全局安装了php-cs-fixer
$wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar -O php-cs-fixer
然后跑步
$sudo chmod a+x php-cs-fixer
$sudo mv php-cs-fixer /usr/local/bin/php-cs-fixer
当我尝试运行php-cs-fixer时
$php-cs-fixer -vv fix /home/xxx/host/master/src/AppBundle/Command/GenerateERPContractInvoicesCommand.php --config=sf2
这会导致以下错误消息:
[PhpCsFixer\ConfigurationException\InvalidConfigurationException (16)]
Cannot read config file “sf2”
尝试使用–config = sf23运行会导致出现相同的错误消息.
试着像这样跑
$php-cs-fixer fix src/AppBundle/Command/GenerateERPContractInvoicesCommand.php --level=symfony
导致错误消息
The “–level” option does not exist.
然后我用内容创建一个配置文件.php_cs
<?php
$finder = Symfony\CS\Finder::create()
->exclude([
'app',
'spec',
'build',
'bin',
'web',
'vendor',
])
->in(__DIR__);
return Symfony\CS\Config::create()
->fixers([
'short_array_syntax',
'-phpdoc_align',
'ordered_use',
])
->finder($finder);
并收到以下错误消息:
[PhpCsFixer\ConfigurationException\InvalidConfigurationException]
The config file: “/home/ivan/host/master/.php_cs” does not return a “PhpCsFixer\ConfigInterface” instance. Got: “integer”.
我如何为Symfony使用php-cs-fixer,你能帮忙吗?
我在哪里可以获得Symfony的配置,以及如何正确使用php-cs-fixer进行Symfony项目?
解决方法:
根据文档,您可能希望使用rules参数运行:
php php-cs-fixer.phar fix /path/to/project --rules=@Symfony
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。