PHP Code Sniffer: Can not correctly run the tool with parameters

已回答

Hi,

I have a very serious problem with PHP Code Sniffer. I configured it according to the instructions:

  1. Download PHP Code Sniffer from GitHub as zip-package ( https://github.com/squizlabs/PHP_CodeSniffer )
  2. File > Settings > Languages & Frameworks > PHP > Code Sniffer > Configuration > [...]
    Path: correct path to code sniffer location.
    Max. messages per file: 50
    Timeout: 30 s.
  3. File > Settings > Editor > Inspections > PHP > PHP Code Sniffer validation
    Check the option on list.
    Check the option beside Show warning as: "Warning"
    Coding standard: PSR2.

When I write the code in my project, I get the message:

PHP Code Sniffer
phpcs: Can not correctly run the tool with parameters:
C:/Users/student/AppData/Local/Temp/phpcs_temp.tmp/index.php
--standard=PSR2
--encoding=utf-8
--report=xml
Possible tool process hangup after 30 sec.

I tried with diffrent versions of PHP (7.1 and 5.6) and diffrent versions of code sniffer (3.2 and 3.1...). The commands "php" and "phpcs" work in the console properly. The file C:/Users/student/AppData/Local/Temp/phpcs_temp.tmp/index.php is created for 30 seconds and then php storm deletes it. I can even type in my console "phpcs C:/Users/student/AppData/Local/Temp/phpcs_temp.tmp/index.php --standard=PSR2 --encoding=utf-8 --report=xml" and it works great, but not in PHPStorm!

XDebug is disabled (I always use "clear" version of PHP with default config).

I'm using Windows 10. My colleagues using PHPStrom on Windows 7 do not have this problem.

Any idea what's wrong with PHPStorm?

4

Same problem here

0

PHPCS version?

Here it's reported that 3.2.0 stopped working in PhpStorm but downgrading back to 3.1.1 makes it work again: https://youtrack.jetbrains.com/issue/WI-39190

There are few tickets about it already -- devs are looking into it.

1

I can confirm that downgrading to 3.1.1 makes it work again on Windows. On Mac I had not issues with the latest 3.* version, same project.

0

Also I can confirm with 3.3.2, Downgrade to ^3.2 fiy the problem again. Is that really a issue on the CS side?

0

Frank, apparently you're seeing a different issue - the problem discussed here is solved in PHP CS v3.2.1.

I've just run my checks with v3.3.2, and it worked. Maybe you were updating your Code Sniffer while trying to run inspections?

0

Thanks Eugene for your comment. However I tried it again, update via composer to 3.3.2, last version, referenced via composer.json with 

"squizlabs/php_codesniffer": "^3",

 

But again the same problem, it is not possible to use the phpcs additional inside the Storm, but always via console. The phpcs is activated in Laguage & Framework --> PHP --> Codesniffer

Use Local, Path <myproject>/vendor/bin/phpcs and validate works fine, use 3.3.2 stable of phpcs.

1

Make sure you can run php in the PhpStorm terminal


1

Yes, as said @Iusicomaxim97 you need Windows to see php. Install it and set a global Path variable.

0

Having the same issue with CS 3.5.4 on PHPStorm 2020.1.1. Does someone found a solution for this? On my case I'm using Linux, not sure if that makes difference.

1

Are you able to run CS in a console with the same parameters? There were no similar reports lately so I would suggest contacting us directly over Help | Contact Support to have a closer look.

0

Thx Dmitry for your reply. The problem is happening when Xdebug is enabled, so I guess I gonna have to run phpcs with another PHP binary where there's no Xdebug running. 

0

Hi, I have the same issue with "phpcs" and "phpcbf" in PhpStorm 2020.1.1 using PHP 7.4.2 with Xdebug v2.8.1. Both work well when I run them in a console but in PhpStorm I always see warnings like this:

PHP_CodeSniffer
phpcs: Can not correctly run the tool with parameters: ...

1

Dmytro, please contact us via Help | Contact Support: we would need to look at your config in details & would have to try to reproduce this on our end.

0

OK, I've submitted a request #2682047.

1

Still the same problem 

PHP CS Fixer: Can not correctly run the tool with parameters: fix

1

I figured out that it works if I set the tool timeout to 20-30 seconds. It seems like the default value of 5 seconds is not enough for large scripts (for example, 1000+ lines of PHP code). And sometimes it looks like even 30 seconds are not enough.

0

Hi Dmytro, do you know the shortcut to access this setting of reducing tool timeout ?

0

Hi, you can find it here:

  • File > Settings... > Languages & Frameworks > PHP > Quality Tools.
  • Click "..." (three dots) button in PHP_CodeSniffer section to see the tool settings.
  • Increase the value of "Tool process timeout, sec [1...30]:" setting from the default 5 seconds to something bigger.

I've finished up with the maximum value of 30 seconds to make it able to process large scripts.

1

请先登录再写评论。