Open designermonkey opened 6 years ago
What is the output of php --version
?
If there is any white space or anything other than php version info on first line, vscode-phpcs outputs errors.
I have encountered 2 errors and it depends on the output before php version line.
phpcs: The phpcs report contains invalid json
happened when I was getting warning about xdebug on cli.
Following error happened when I had enabled incompatible php extension accidentally.
phpcs: Unable to locate phpcs. Invalid version string encountered
Hope it helps.
Has the same issue today, in my case, there are some special control characters in php files.
php -l target.php | vim -
output:
| ERROR | [ ] Expected "if (...) {\n"; found "if (...) // ^Z^Z^Z^Z^Z^Z^Z^Z^Z^Z\n
Remove the control characters, everything works fine again.
Had the same problem. Was trying to debug and came across a line in #100
This error, as described in the readme, means that the output of the phpcs command is not valid json. This can happen when additional messages, are appended to the phpcs json output such as PHP Exceptions, Errors, progress, etc.
Realized my config file was set to output a full report
<arg name="report-full"/>
Disabled this line and everything worked as expected. Noticed the OP had this line in their config too. Hope this helps.
Issue resolved in https://github.com/ikappas/vscode-phpcs/pull/164
I get the error only when my path has some space for example:
/Users/myuser/projects/phpcs/bin/phpcs --report=json -q --encoding=UTF-8 --error-severity=5 --warning-severity=5 --stdin-path=/Users/myuser/Local Sites/plugintest/app/public/wp-content/plugins/myplugin.php
I get the error but if I run this with double-quote it works.
/Users/myuser/projects/phpcs/bin/phpcs --report=json -q --encoding=UTF-8 --error-severity=5 --warning-severity=5 --stdin-path="/Users/myuser/Local Sites/plugintest/app/public/wp-content/plugins/myplugin.php"
Regards,
Same problem as #100 but none of the suggestions fix it.
My config:
My PHP CS Xml:
I have this config as this is set up as a composer command also.
phpcs version (local and global composer): 3.2.3
Is there any way to see any debug output for this extension? Any suggestions would be appreciated as this is driving me nuts.