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

时间:2021-09-25 07:18:16

I have a laravel application (created with composer) that I am trying to ensure meets PHP coding standards (level PSR-1). I run:

我有一个laravel应用程序(用作曲家创建),我试图确保符合PHP编码标准(级别PSR-1)。我跑:

$ phpcs --standard=PSR1 my_app/

And within a few seconds it returns with just a new, empty, ready-to-go command line:

在几秒钟之内它只返回一个新的,空的,准备好的命令行:

$

Does this mean my code meets all requirements and standards in PSR-1? It does the same with just:

这是否意味着我的代码符合PSR-1中的所有要求和标准?它只是做同样的事情:

$ phpcs my_app/
$ phpcs --standard=PEAR my_app/
$ phpcs --standard=PSR1 --report=summary lauras_app/

I just want to make sure that if the commands return nothing, that means my code is in standard. Thank you!

我只是想确保如果命令什么都不返回,那意味着我的代码是标准的。谢谢!

1 个解决方案

#1


1  

Phpcs does not output anything if it does detect no errors. From their doc:

如果Phpcs没有检测到任何错误,则不输出任何内容。从他们的文档:

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.

默认情况下,PHP_CodeSniffer将安静地运行,仅在末尾打印错误和警告的报告。如果要检查大量文件,则可能需要等待一段时间才能看到该报告。如果您想知道发生了什么,可以打开进度或详细输出。

There are 2 different options to see what phpcs is doing.

有两种不同的选项可以看看phpcs正在做什么。

Using show_progress

使用show_progress

With progress output enabled, PHP_CodeSniffer will print a single-character status for each file being checked

启用进度输出后,PHP_CodeSniffer将为每个要检查的文件打印单字符状态

phpcs --config-set show_progress 1 --standard=PSR1 my_app/

or -p.

或-p。

phpcs -p --standard=PSR1 my_app/

The second option is to use the verbose flag -v. You can set it up to -vvv to increase the details.

第二种选择是使用详细标志-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.

启用详细输出后,PHP_CodeSniffer将打印正在检查的文件,显示文件包含的令牌和行数,并告知您处理所需的时间。

phpcs -v --standard=PSR1 my_app/

#1


1  

Phpcs does not output anything if it does detect no errors. From their doc:

如果Phpcs没有检测到任何错误,则不输出任何内容。从他们的文档:

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.

默认情况下,PHP_CodeSniffer将安静地运行,仅在末尾打印错误和警告的报告。如果要检查大量文件,则可能需要等待一段时间才能看到该报告。如果您想知道发生了什么,可以打开进度或详细输出。

There are 2 different options to see what phpcs is doing.

有两种不同的选项可以看看phpcs正在做什么。

Using show_progress

使用show_progress

With progress output enabled, PHP_CodeSniffer will print a single-character status for each file being checked

启用进度输出后,PHP_CodeSniffer将为每个要检查的文件打印单字符状态

phpcs --config-set show_progress 1 --standard=PSR1 my_app/

or -p.

或-p。

phpcs -p --standard=PSR1 my_app/

The second option is to use the verbose flag -v. You can set it up to -vvv to increase the details.

第二种选择是使用详细标志-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.

启用详细输出后,PHP_CodeSniffer将打印正在检查的文件,显示文件包含的令牌和行数,并告知您处理所需的时间。

phpcs -v --standard=PSR1 my_app/