PHP_CodeSniffer icon indicating copy to clipboard operation
PHP_CodeSniffer copied to clipboard

Warning with xdebug enabled causes invalid json

Open rollecode opened this issue 5 years ago • 4 comments

Describe the bug

Produces "Xdebug: [Step Debug] Could not connect to debugging client. Tried: 127.0.0.1:9003 (through xdebug.client_host/xdebug.client_port) :-(" when running command:

/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

AFAIK phpcs cli doesn't really need xdebug but will produce error in Visual Studio Code (vscode-phpcs) because the command line client warns for not being able to connect to debugging client. This means vscode-phpcs cannot lint at all despite phpcs is working fine WITH the error.

Code sample

Any code.

Custom ruleset

phpcs.xml

To reproduce Steps to reproduce the behavior:

  1. Install xdebug
  2. Run phpcs test.php ...
  3. See error message displayed
PHPCS output here

Expected behavior No errors, valid json with --report=json.

Versions (please complete the following information):

  • OS: macOS Catalina 10.15.7
  • PHP: 7.3.21
  • PHPCS: 3.5.5 (stable)
  • Standard: The installed coding standards are PEAR, Zend, PSR2, MySource, Squiz, PSR1, PSR12, PHPCompatibility, WordPress, WordPress-Extra, WordPress-Docs and WordPress-Core

Additional context

Also asked here.

rollecode avatar Feb 24 '21 13:02 rollecode

This error isn't coming from PHP_CodeSniffer. PHPCS does not use xdebug in any way.

This is likely a PHP or VSCode configuration issue, so closing as there isn't any change I can make to help you here.

gsherwood avatar Feb 24 '21 21:02 gsherwood

Hello @ronilaukkarinen,I'm facing the same issue. Can you help me out?

PramitBhar avatar Apr 11 '24 05:04 PramitBhar

Hello @ronilaukkarinen,I'm facing the same issue. Can you help me out?

We don't have this problem any more, this was 3 years ago. You can check out the possible workaround here. Sorry that I can't be more of help here.

rollecode avatar Apr 11 '24 07:04 rollecode

Hello @ronilaukkarinen,I'm facing the same issue. Can you help me out?

We don't have this problem any more, this was 3 years ago. You can check out the possible workaround here. Sorry that I can't be more of help here.

Thanks for reply.

PramitBhar avatar Apr 11 '24 08:04 PramitBhar