I have a vscode plugin that uses phpcs for linting.
I get this error:
phpcs: Unknown error ocurred. Please verify that C:\Users\David\AppData\Roaming\Composer\vendor\bin\phpcs --report=json -q --encoding=UTF-8 --standard=dev/setup/codesniffer/ruleset.xml --error-severity=5 --warning-severity=5 --stdin-path=C:\xampp7\htdocs\person.class.php - returns a valid json object.
If I run the command on the terminal with error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
I get this output:
{"totals":{"errors":0,"warnings":0,"fixable":0},"files":{"C:\\xampp7\\htdocs\\person.class.php":{"errors":0,"warnings":0,"messages":[]}}}
If I run the command on the terminal with error_reporting = E_ALL
I get this output:
Xdebug: [Config] The setting 'xdebug.trace_output_dir' has been renamed, see the upgrading guide at https://xdebug.org/docs/upgrade_guide#changed-xdebug.trace_output_dir (See: https://xdebug.org/docs/errors#CFG-C-CHANGED)
{"totals":{"errors":0,"warnings":0,"fixable":0},"files":{"C:\\xampp7\\htdocs\\person.class.php":{"errors":0,"warnings":0,"messages":[]}}}
I know I can just fix xdebug.trace_output_dir
but something else will pop up in the future.
How can I fix this? Isn't display_errors = Off
to avoid this kind of stuff?
I can point the plugin to the executable phpcs.bat
@echo off
REM PHP_CodeSniffer detects violations of a defined coding standard.
REM
REM @author Greg Sherwood <gsherwood@squiz.net>
REM @copyright 2006-2015 Squiz Pty Ltd (ABN 77 084 670 600)
REM @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
if "%PHP_PEAR_PHP_BIN%" neq "" (
set PHPBIN=%PHP_PEAR_PHP_BIN%
) else set PHPBIN=php
"%PHPBIN%" -d display_errors=off "%~dp0\phpcs" %*
Here I can set options like -d display_errors=off
which I already have on php.ini
Here's the relevant options:
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
error_reporting = E_ALL
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
This shows the Xdebug error.
error_reporting = E_ALL
error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
display_errors = Off
display_startup_errors = Off
log_errors = On
log_errors_max_len = 1024
This does not.
Could it be that xdebug is printing to STDOUT instead of STDERR?
For now I'll make do with this php -d error_reporting=22527 -r "echo E_ALL & ~E_DEPRECATED & ~E_STRICT;"
Errors again.
php -i | grep "error"
display_errors => STDERR => STDERR
display_startup_errors => On => On
error_append_string => no value => no value
error_log => C:/xampp7\php\logs\php_error_log => C:/xampp7\php\logs\php_error_log
error_prepend_string => no value => no value
error_reporting => 32767 => 32767
html_errors => Off => Off
ignore_repeated_errors => Off => Off
log_errors => On => On
log_errors_max_len => 1024 => 1024
track_errors => Off => Off
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
intl.error_level => 0 => 0
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.show_error_trace => Off => Off
xdebug.start_upon_error => default => default
php -d error_reporting=22527 -d display_errors=off -i | grep "error"
display_errors => Off => Off
display_startup_errors => On => On
error_append_string => no value => no value
error_log => C:/xampp7\php\logs\php_error_log => C:/xampp7\php\logs\php_error_log
error_prepend_string => no value => no value
error_reporting => 22527 => 22527
html_errors => Off => Off
ignore_repeated_errors => Off => Off
log_errors => On => On
log_errors_max_len => 1024 => 1024
track_errors => Off => Off
xmlrpc_error_number => 0 => 0
xmlrpc_errors => Off => Off
intl.error_level => 0 => 0
xdebug.force_display_errors => Off => Off
xdebug.force_error_reporting => 0 => 0
xdebug.show_error_trace => Off => Off
xdebug.start_upon_error => default => default
However if I do this:
php -d error_reporting=22527 -d display_errors=off "C:\Users\david\Documents\PHP_CodeSniffer\bin\\phpcs" --version
I get errors:
PHP PHP_CodeSniffer\Exceptions\DeepExitException: PHP_CodeSniffer version 3.7.2 (stable) by Squiz (http://www.squiz.net)
in C:\Users\david\Documents\PHP_CodeSniffer\src\Config.php on line 713
PHP Stack trace:
PHP 1. {main}() C:\Users\david\Documents\PHP_CodeSniffer\bin\phpcs:0
PHP 2. PHP_CodeSniffer\Runner->runPHPCS() C:\Users\david\Documents\PHP_CodeSniffer\bin\phpcs:18
PHP 3. PHP_CodeSniffer\Config->__construct($cliArgs = *uninitialized*, $dieOnUnknownArg = *uninitialized*) C:\Users\david\Documents\PHP_CodeSniffer\src\Runner.php:67
PHP 4. PHP_CodeSniffer\Config->setCommandLineValues($args = [0 => '--version']) C:\Users\david\Documents\PHP_CodeSniffer\src\Config.php:342
PHP 5. PHP_CodeSniffer\Config->processLongArgument($arg = 'version', $pos = 0) C:\Users\david\Documents\PHP_CodeSniffer\src\Config.php:441
PHP_CodeSniffer version 3.7.2 (stable) by Squiz (http://www.squiz.net)
The first problem was solved with -d error_reporting=22527 -d display_errors=off
The second problem was solved with -d xdebug.show_exception_trace=0