简体   繁体   English

使用phpcbf.phar修复PSR2错误

[英]Fixing PSR2 errors with phpcbf.phar

I am trying to fix PSR2 error using the pcpcbf.phar file released from squizlabs - http://www.squizlabs.com/php-codesniffer 我试图使用修复PSR2错误pcpcbf.phar从squizlabs发布文件- http://www.squizlabs.com/php-codesniffer

I am running the following command to fix the file home.php: 我正在运行以下命令来修复文件home.php:

php phpcbf.phar --standard=PSR2 "home.php"

which returns the following error: 返回以下错误:

"patch is not recognised as an internal or external command, operable program or batch file"

Anyone came upon this issue and knows how to resolve it? 有人遇到这个问题,知道如何解决吗? Thanks 谢谢

The error indicates that you don't have the patch command installed, which PHPCBF uses to apply changes in one action. 该错误表明您没有安装patch命令,PHPCBF使用该命令在一项操作中应用更改。

If you are running on Windows, you can install Cygwin with the patch package and PHPCBF will run without error. 如果您在Windows上运行,则可以使用补丁程序包安装Cygwin,PHPCBF将运行而不会出现错误。 Other operating systems will either have patch installed already or a package manager to help you out. 其他操作系统将已经安装了补丁程序或软件包管理器来帮助您。

If you don't want to install anything, you can specify the --no-patch argument to PHPCBF, which will instruct PHPCBF to apply the changes to your files directly, one at a time as they are checked. 如果您不想安装任何内容,则可以为PHPCBF指定--no-patch参数,该参数将指示PHPCBF将更改直接应用于文件,一次检查一次。

If you don't want the files to be overwritten, you can use the --suffix command line argument to write fixed copies of the files instead. 如果您不想覆盖文件,则可以使用--suffix命令行参数来写文件的固定副本。

More instructions, and examples of using --no-patch and --suffix , can be found here: https://github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically#using-the-php-code-beautifier-and-fixer 可在此处找到更多说明以及使用--no-patch--suffix示例: https : //github.com/squizlabs/PHP_CodeSniffer/wiki/Fixing-Errors-Automatically#using-the-php-code-美化和修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM