vscode-phpcs icon indicating copy to clipboard operation
vscode-phpcs copied to clipboard

phpcs: Unable to locate phpcs. Invalid version string encountered!

Open needrunning opened this issue 6 years ago • 5 comments
trafficstars

mac system

install phpcs via composer global require squizlabs/php_codesniffer

open vscode

installed phpcs extention

config it

exepath /Users/usernama/.composer/vendor/squizlabs/php_codesniffer/bin/phpcs

show that

phpcs: Unable to locate phpcs. Invalid version string encountered!

needrunning avatar Jul 12 '19 02:07 needrunning

Yes, I've also been having this issue since the last vscode update.

JAW-Dev avatar Aug 18 '19 19:08 JAW-Dev

I use windows system and have the same problem. Have you solved it?

XLearner avatar Sep 17 '19 03:09 XLearner

I have solved it via install PHP CodeSniffe on my system phpcs

https://www.jianshu.com/p/8c16b1f247ed phpcs

needrunning avatar Oct 29 '19 09:10 needrunning

In my case, I'm getting this error because of a PHP deprecation notice that is output when phpcs --version is run. The regex expects the output of that command to start with PHP_CodeSniffer version, followed by the version number, but the deprecation notice is printed before that, causing the version to not be matched.

davisben avatar Jan 09 '21 18:01 davisben

I have the same problem. php dump a warning message before any executed command and then the

.\vendor\squizlabs\php_codesniffer\bin\phpcs --version

dump this message:

PHP Warning:  Version warning: Imagick was compiled against ImageMagick version 1799 but version 1802 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0

Warning: Version warning: Imagick was compiled against ImageMagick version 1799 but version 1802 is loaded. Imagick will run but may behave surprisingly in Unknown on line 0
PHP_CodeSniffer version 3.5.8 (stable) by Squiz (http://www.squiz.net)

I try to change error_reporting inside the php.ini from E_ALL to E_ERROR. and then the result of

.\vendor\squizlabs\php_codesniffer\bin\phpcs --version

changed to

PHP_CodeSniffer version 3.5.8 (stable) by Squiz (http://www.squiz.net)

and my problem was resolved.

@davisben Thank you.

mjavadhpour avatar Mar 09 '21 17:03 mjavadhpour