我有一个vscode插件,它使用phpcs来做掉毛。
我得到这个错误:
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.
如果我使用error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT
在终端上运行该命令,则会得到以下输出:
{"totals":{"errors":0,"warnings":0,"fixable":0},"files":{"C:\\xampp7\\htdocs\\person.class.php":{"errors":0,"warnings":0,"messages":[]}}}
如果我使用error_reporting = E_ALL
在终端上运行该命令,则会得到以下输出:
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":[]}}}
我知道我可以只修复xdebug.trace_output_dir
,但将来会弹出其他东西。
我该怎么解决这个问题?display_errors = Off
不是为了避免这种事情吗?
编辑:
我可以将插件指向可执行文件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" %*
在这里,我可以设置-d display_errors=off
等选项,而php.ini
上已经有了这些选项
以下是相关选项:
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
这显示了Xdebug错误。
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
但这不是。
可能是xdebug打印到STDOUT而不是STDERR吗?
编辑2:
现在我将使用这个php -d error_reporting=22527 -r "echo E_ALL & ~E_DEPRECATED & ~E_STRICT;"
编辑3:
又出错了。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
但是,如果我这样做:php -d error_reporting=22527 -d display_errors=off "C:\Users\david\Documents\PHP_CodeSniffer\bin\\phpcs" --version
我收到错误:
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)
1条答案
按热度按时间iqjalb3h1#
第一个问题已使用
-d error_reporting=22527 -d display_errors=off
解决第二个问题是使用
-d xdebug.show_exception_trace=0
解决的