ikappas / vscode-phpcs

PHP CodeSniffer for Visual Studio Code
MIT License
128 stars 56 forks source link

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

Open needrunning opened 5 years ago

needrunning commented 5 years ago

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!

JAW-Dev commented 5 years ago

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

XLearner commented 4 years ago

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

needrunning commented 4 years ago

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

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

davisben commented 3 years ago

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.

mjavadhpour commented 3 years ago

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.