13

PHP Code Sniffer

phpcs: Can not correctly run the tool with parameters:
C:\Users\sa\AppData\Local\Temp\___0.tmp\press_home.module --encoding=utf-8
Possible tool process hangup after 5 sec.
Exclude press_home.module from PHP Code Sniffer analysis.

PhpStorm throwing this message frequently. Any idea why PhpStorm showing this error?

LazyOne
  • 158,824
  • 45
  • 388
  • 391
Shakir Blouch
  • 187
  • 1
  • 5
  • 14
  • 1
    Extremely likely because PHP executable that is used to execute `phpcs` has xdebug enabled. 2 possible solutions: 1) somehow make sure that it has no xdebug enabled (i.e. have couple of php installations where default one has no xdebug) 2) Increase timeout in PhpStorm settings – LazyOne Aug 25 '15 at 10:54
  • @LazyOne thanks for your helpful comment . I am going with solution 1 . Disabled the xdebug . and now the error is not coming . – Shakir Blouch Aug 25 '15 at 11:52

2 Answers2

18

Any idea why PhpStorm showing this error?

Extremely likely because PHP executable that is used to execute phpcs has xdebug enabled -- execution takes longer.

Two possible solutions:

  1. Make sure that PHP executable that is used to execute phpcs has no xdebug enabled. E.g. you may disable xdebug altogether .. or have multiple PHP installations on your computer where default one (that will be used if you type php in terminal) does not have xdebug.

  2. Try increasing timeout in PhpStorm's settings (Settings/Preferences | Languages & Frameworks | PHP | Code Sniffer). On certain systems/setups even increasing timeout to 20+ seconds (which is a lot) may still unable to resolve the issue.

Solution described in #1 is preferred from performance point of view and more reliable (but more difficult to implement, especially if you actually need xdebug locally).

LazyOne
  • 158,824
  • 45
  • 388
  • 391
  • I have the same problem on Windows 10. XDebug is disabled and timeout is set on maximum value (30 sec) - but this solution doesn't work. – ZaquPL Dec 10 '17 at 10:35
  • @ZaquPL But it worked for the question author .. and other people who upvoted. If it does not work for you (**2 year old** answer) then it does not mean that it will not work for others as well -- you may simply have different situation ... or some new issue in actual PhpStorm. At the time of writing the answer the proposed solutions were able to resolve the issue. – LazyOne Dec 10 '17 at 10:57
0

Increasing a timeout should only be applied when you have good reasons (complex data, remote connection etc.), but most scenarios are analyzed quickly.

Potential Solution for your problem: You are not providing a code standard as a parameter, so make sure that PHPStorm is calling phpcs with a proper coding standard, thus leaving out the --standard parameter may cause problems.

In PHPStorm under Settings->Editor->Inspections, expand PHP and go to PHP Code Sniffer validation. There you should find a dropdown select labeled "Coding standard".

I wouldn't recommend using the default MySource as a value if you haven't got a good reason, instead select PSR2, for example.

The following command would be issued by PHPStorm, in this case:

phpcs.bat index.php --standard=PSR2 --encoding=utf-8 --report=xml
TayTay
  • 6,882
  • 4
  • 44
  • 65