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

Command with xdebug enabled causes invalid json

Open ronilaukkarinen opened this issue 4 years ago • 5 comments

Phpcs doesn't really need xdebug but will produce error because the command warns for not being able to connect to debugging client. This means vscode-phpcs cannot lint at all despite phpcs is working fine:

$ /usr/local/bin/phpcs --report=json -q -s --encoding=UTF-8 --standard=/Users/rolle/Projects/airdev/content/themes/air-light/phpcs.xml --error-severity=5 --warning-severity=5 --stdin-path=/Users/rolle/Projects/airdev/content/themes/air-light/inc/includes/nav-walker.php
Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9003 (through xdebug.client_host/xdebug.client_port) :-(
{"totals":{"errors":10,"warnings":13,"fixable":10},"files":{"\/Users\/rolle\/Projects\/airdev\/content\/themes\/air-light\/functions.php":{"errors":0 
<truncated>

Any way to disable xdebug (also asked in PHP_Codesniffer issue) OR add environment variable XDEBUG_MODE=off before the executable? We have "solved" this for now with our custom executable script as described here.

ronilaukkarinen avatar Feb 24 '21 13:02 ronilaukkarinen

@ronilaukkarinen thanks for the workaround 👍

tribal2 avatar Nov 11 '21 17:11 tribal2

@tribal2 No problem, glad you found it useful!

ronilaukkarinen avatar Nov 11 '21 19:11 ronilaukkarinen

Another workaround, as at xdebug 3.1, is to ensure it can write to its own log file as defined by xdebug.log = <file> in php.ini. If you do this, that particular warning will not longer be pushed to stdout.

enjibby avatar Apr 15 '22 00:04 enjibby

Another workaround, as at xdebug 3.1, is to ensure it can write to its own log file as defined by xdebug.log = <file> in php.ini. If you do this, that particular warning will not longer be pushed to stdout.

Thanks for that, Quick and easy fix, works very well for me.

fvelcker avatar Apr 20 '22 17:04 fvelcker