PhpStorm Is throwing an error for phpcs

好久不见. 提交于 2019-12-06 19:50:45

问题


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?


回答1:


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).




回答2:


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


来源:https://stackoverflow.com/questions/32201991/phpstorm-is-throwing-an-error-for-phpcs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!