我有一个 Laravel 应用程序(使用 Composer 创建),我试图确保它符合 PHP 编码标准(级别 PSR-1)。我跑:
$ phpcs --standard=PSR1 my_app/
然后在几秒钟内它返回一个新的、空的、准备就绪的命令行:
$
这是否意味着我的代码满足 PSR-1 中的所有要求和标准?它与 just 的作用相同:
$ phpcs my_app/
$ phpcs --standard=PEAR my_app/
$ phpcs --standard=PSR1 --report=summary lauras_app/
我只是想确保如果命令不返回任何内容,这意味着我的代码是标准的。谢谢!
最佳答案
如果 Phpcs 没有检测到错误,它就不会输出任何东西。 来自他们的 doc :
By default, PHP_CodeSniffer will run quietly, only printing the report of errors and warnings at the end. If you are checking a large number of files, you may have to wait a while to see the report. If you want to know what is happening, you can turn on progress or verbose output.
有 2 个不同的选项可以查看 phpcs
正在做什么。
使用show_progress
With progress output enabled, PHP_CodeSniffer will print a single-character status for each file being checked
phpcs --config-set show_progress 1 --standard=PSR1 my_app/
或-p
。
phpcs -p --standard=PSR1 my_app/
第二个选项是使用详细标志 -v
。您可以将其设置为-vvv
以增加细节。
With verbose output enabled, PHP_CodeSniffer will print the file that it is checking, show you how many tokens and lines the file contains, and let you know how long it took to process.
phpcs -v --standard=PSR1 my_app/
关于php codesniffer 什么都不返回……我的代码是标准的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38171658/