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:
- Download PHP Code Sniffer from GitHub as zip-package ( https://github.com/squizlabs/PHP_CodeSniffer )
-
File > Settings > Languages & Frameworks > PHP > Code Sniffer > Configuration > [...]
Path: correct path to code sniffer location.
Max. messages per file: 50
Timeout: 30 s. -
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?
Please sign in to leave a comment.
Same problem here
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.
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.
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?
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?
Thanks Eugene for your comment. However I tried it again, update via composer to 3.3.2, last version, referenced via composer.json with
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.
Make sure you can run php in the PhpStorm terminal
Yes, as said @Iusicomaxim97 you need Windows to see php. Install it and set a global Path variable.
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.
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.
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.
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: ...
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.
OK, I've submitted a request #2682047.
Still the same problem
PHP CS Fixer: Can not correctly run the tool with parameters: fix
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.
Hi Dmytro, do you know the shortcut to access this setting of reducing tool timeout ?
Hi, you can find it here:
I've finished up with the maximum value of 30 seconds to make it able to process large scripts.