1

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

cucurbit
  • 1,422
  • 1
  • 13
  • 32
George
  • 89
  • 2
  • 9

1 Answers1

4

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

Greg Sherwood
  • 6,992
  • 2
  • 29
  • 24
  • Thanks Greg, it appears the --no patch fixed the error, but when i run the command 'php phpcbf.phar --standard=PSR2 --no-patch "/360/My360Site Project/My360Site/home.php"' to fix my homepage file, it returns "Fixed 0 Files", although the command 'phpcs --standard=PSR2 "/360/My360Site Project/My360Site/home.php"' returns 19 errors. Any idea why none of the errors gets fixed? – George Jun 04 '14 at 08:59
  • Sorry I missed this comment. I've been working on PHPCBF a lot lately, so trying again with the latest code would be good; the output is also much clearer. You can also run `phpcs --report=diff -vv [the rest of your command here]` to see what is happening during fixing. It is likely that either the errors can not be fixed, or a conflict is occurring that stops the fixes from working. – Greg Sherwood Nov 22 '14 at 00:28