简体   繁体   中英

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

I am running the following command to fix the file 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.

If you are running on Windows, you can install Cygwin with the patch package and PHPCBF will run without error. 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.

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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