function ErrorHandler::handle
Error handler
@static
Parameters
int $level Level of the error raised:
string $message Error message:
string $file Filename that the error was raised in:
int $line Line number the error was raised at:
Throws
\ErrorException
File
-
vendor/
composer/ composer/ src/ Composer/ Util/ ErrorHandler.php, line 38
Class
- ErrorHandler
- Convert PHP errors into exceptions
Namespace
Composer\UtilCode
public static function handle(int $level, string $message, string $file, int $line) : bool {
$isDeprecationNotice = $level === E_DEPRECATED || $level === E_USER_DEPRECATED;
// error code is not included in error_reporting
if (!$isDeprecationNotice && 0 === (error_reporting() & $level)) {
return true;
}
if (filter_var(ini_get('xdebug.scream'), FILTER_VALIDATE_BOOLEAN)) {
$message .= "\n\nWarning: You have xdebug.scream enabled, the warning above may be" . "\na legitimately suppressed error that you were not supposed to see.";
}
if (!$isDeprecationNotice) {
throw new \ErrorException($message, 0, $level, $file, $line);
}
if (self::$io !== null) {
self::$io->writeError('<warning>Deprecation Notice: ' . $message . ' in ' . $file . ':' . $line . '</warning>');
if (self::$io->isVerbose()) {
self::$io->writeError('<warning>Stack trace:</warning>');
self::$io->writeError(array_filter(array_map(static function ($a) : ?string {
if (isset($a['line'], $a['file'])) {
return '<warning> ' . $a['file'] . ':' . $a['line'] . '</warning>';
}
return null;
}, array_slice(debug_backtrace(), 2)), function (?string $line) {
return $line !== null;
}));
}
}
return true;
}