mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 12:55:26 +01:00
Merge pull request #8724 from kkmuffme/include-cli-args-in-php-errors
This commit is contained in:
commit
7869cb548a
@ -62,7 +62,7 @@ final class LanguageServer
|
||||
public static function run(array $argv): void
|
||||
{
|
||||
gc_disable();
|
||||
ErrorHandler::install();
|
||||
ErrorHandler::install($argv);
|
||||
$valid_short_options = [
|
||||
'h',
|
||||
'v',
|
||||
|
@ -168,7 +168,7 @@ final class Psalm
|
||||
gc_collect_cycles();
|
||||
gc_disable();
|
||||
|
||||
ErrorHandler::install();
|
||||
ErrorHandler::install($argv);
|
||||
|
||||
$args = array_slice($argv, 1);
|
||||
|
||||
@ -191,7 +191,6 @@ final class Psalm
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
if (array_key_exists('h', $options)) {
|
||||
echo self::getHelpText();
|
||||
/*
|
||||
|
@ -97,7 +97,7 @@ final class Psalter
|
||||
gc_collect_cycles();
|
||||
gc_disable();
|
||||
|
||||
ErrorHandler::install();
|
||||
ErrorHandler::install($argv);
|
||||
|
||||
self::setMemoryLimit();
|
||||
|
||||
|
@ -72,7 +72,7 @@ final class Refactor
|
||||
gc_collect_cycles();
|
||||
gc_disable();
|
||||
|
||||
ErrorHandler::install();
|
||||
ErrorHandler::install($argv);
|
||||
|
||||
$args = array_slice($argv, 1);
|
||||
|
||||
|
@ -8,6 +8,7 @@ use Throwable;
|
||||
use function defined;
|
||||
use function error_reporting;
|
||||
use function fwrite;
|
||||
use function implode;
|
||||
use function ini_set;
|
||||
use function set_error_handler;
|
||||
use function set_exception_handler;
|
||||
@ -24,8 +25,15 @@ final class ErrorHandler
|
||||
/** @var bool */
|
||||
private static $exceptions_enabled = true;
|
||||
|
||||
public static function install(): void
|
||||
/** @var string */
|
||||
private static $args = '';
|
||||
|
||||
/**
|
||||
* @param array<int,string> $argv
|
||||
*/
|
||||
public static function install(array $argv = array()): void
|
||||
{
|
||||
self::$args = implode(' ', $argv);
|
||||
self::setErrorReporting();
|
||||
self::installErrorHandler();
|
||||
self::installExceptionHandler();
|
||||
@ -67,7 +75,9 @@ final class ErrorHandler
|
||||
): bool {
|
||||
if (ErrorHandler::$exceptions_enabled && ($error_code & error_reporting())) {
|
||||
throw new RuntimeException(
|
||||
'PHP Error: ' . $error_message . ' in ' . $error_filename . ':' . $error_line,
|
||||
'PHP Error: ' . $error_message
|
||||
. ' in ' . $error_filename . ':' . $error_line
|
||||
. ' for command with CLI args "' . ErrorHandler::$args . '"',
|
||||
$error_code
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user