php codesniffer 什么都不返回……我的代码是标准的吗?

标签 php pear code-standards phpcodesniffer psr-1

我有一个 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/

相关文章:

php - 以图像格式保存输出数据

php - 如何忽略行长 PHP_CodeSniffer

typescript - 如何创建我的自定义 tslint 规则集?

php - 在 wampserver 上安装 PEAR

php - pear 模块类未定义

java - Sonarqube 在计算新错误/漏洞/泄漏时不尊重 git 提交日期

php - 如何获取 PHP 核心函数列表以便编写函数包装器

php - 有什么方法可以打印 mysqli->execute() 进行的实际查询吗?

php - 除非所有列都存在,否则 Mysqli INSERT 不起作用

php - RabbitMq:替换重复的消息