comparison vendor/symfony/debug/ErrorHandler.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents c2387f117808
children af1871eacc83
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
9 * file that was distributed with this source code. 9 * file that was distributed with this source code.
10 */ 10 */
11 11
12 namespace Symfony\Component\Debug; 12 namespace Symfony\Component\Debug;
13 13
14 use Psr\Log\LoggerInterface;
14 use Psr\Log\LogLevel; 15 use Psr\Log\LogLevel;
15 use Psr\Log\LoggerInterface;
16 use Symfony\Component\Debug\Exception\ContextErrorException; 16 use Symfony\Component\Debug\Exception\ContextErrorException;
17 use Symfony\Component\Debug\Exception\FatalErrorException; 17 use Symfony\Component\Debug\Exception\FatalErrorException;
18 use Symfony\Component\Debug\Exception\FatalThrowableError; 18 use Symfony\Component\Debug\Exception\FatalThrowableError;
19 use Symfony\Component\Debug\Exception\OutOfMemoryException; 19 use Symfony\Component\Debug\Exception\OutOfMemoryException;
20 use Symfony\Component\Debug\Exception\SilencedErrorContext; 20 use Symfony\Component\Debug\Exception\SilencedErrorContext;
21 use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
22 use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface;
21 use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler; 23 use Symfony\Component\Debug\FatalErrorHandler\UndefinedFunctionFatalErrorHandler;
22 use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler; 24 use Symfony\Component\Debug\FatalErrorHandler\UndefinedMethodFatalErrorHandler;
23 use Symfony\Component\Debug\FatalErrorHandler\ClassNotFoundFatalErrorHandler;
24 use Symfony\Component\Debug\FatalErrorHandler\FatalErrorHandlerInterface;
25 25
26 /** 26 /**
27 * A generic ErrorHandler for the PHP engine. 27 * A generic ErrorHandler for the PHP engine.
28 * 28 *
29 * Provides five bit fields that control how errors are handled: 29 * Provides five bit fields that control how errors are handled:
46 * @author Nicolas Grekas <p@tchwork.com> 46 * @author Nicolas Grekas <p@tchwork.com>
47 * @author Grégoire Pineau <lyrixx@lyrixx.info> 47 * @author Grégoire Pineau <lyrixx@lyrixx.info>
48 */ 48 */
49 class ErrorHandler 49 class ErrorHandler
50 { 50 {
51 private $levels = array( 51 private $levels = [
52 E_DEPRECATED => 'Deprecated', 52 E_DEPRECATED => 'Deprecated',
53 E_USER_DEPRECATED => 'User Deprecated', 53 E_USER_DEPRECATED => 'User Deprecated',
54 E_NOTICE => 'Notice', 54 E_NOTICE => 'Notice',
55 E_USER_NOTICE => 'User Notice', 55 E_USER_NOTICE => 'User Notice',
56 E_STRICT => 'Runtime Notice', 56 E_STRICT => 'Runtime Notice',
62 E_RECOVERABLE_ERROR => 'Catchable Fatal Error', 62 E_RECOVERABLE_ERROR => 'Catchable Fatal Error',
63 E_COMPILE_ERROR => 'Compile Error', 63 E_COMPILE_ERROR => 'Compile Error',
64 E_PARSE => 'Parse Error', 64 E_PARSE => 'Parse Error',
65 E_ERROR => 'Error', 65 E_ERROR => 'Error',
66 E_CORE_ERROR => 'Core Error', 66 E_CORE_ERROR => 'Core Error',
67 ); 67 ];
68 68
69 private $loggers = array( 69 private $loggers = [
70 E_DEPRECATED => array(null, LogLevel::INFO), 70 E_DEPRECATED => [null, LogLevel::INFO],
71 E_USER_DEPRECATED => array(null, LogLevel::INFO), 71 E_USER_DEPRECATED => [null, LogLevel::INFO],
72 E_NOTICE => array(null, LogLevel::WARNING), 72 E_NOTICE => [null, LogLevel::WARNING],
73 E_USER_NOTICE => array(null, LogLevel::WARNING), 73 E_USER_NOTICE => [null, LogLevel::WARNING],
74 E_STRICT => array(null, LogLevel::WARNING), 74 E_STRICT => [null, LogLevel::WARNING],
75 E_WARNING => array(null, LogLevel::WARNING), 75 E_WARNING => [null, LogLevel::WARNING],
76 E_USER_WARNING => array(null, LogLevel::WARNING), 76 E_USER_WARNING => [null, LogLevel::WARNING],
77 E_COMPILE_WARNING => array(null, LogLevel::WARNING), 77 E_COMPILE_WARNING => [null, LogLevel::WARNING],
78 E_CORE_WARNING => array(null, LogLevel::WARNING), 78 E_CORE_WARNING => [null, LogLevel::WARNING],
79 E_USER_ERROR => array(null, LogLevel::CRITICAL), 79 E_USER_ERROR => [null, LogLevel::CRITICAL],
80 E_RECOVERABLE_ERROR => array(null, LogLevel::CRITICAL), 80 E_RECOVERABLE_ERROR => [null, LogLevel::CRITICAL],
81 E_COMPILE_ERROR => array(null, LogLevel::CRITICAL), 81 E_COMPILE_ERROR => [null, LogLevel::CRITICAL],
82 E_PARSE => array(null, LogLevel::CRITICAL), 82 E_PARSE => [null, LogLevel::CRITICAL],
83 E_ERROR => array(null, LogLevel::CRITICAL), 83 E_ERROR => [null, LogLevel::CRITICAL],
84 E_CORE_ERROR => array(null, LogLevel::CRITICAL), 84 E_CORE_ERROR => [null, LogLevel::CRITICAL],
85 ); 85 ];
86 86
87 private $thrownErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED 87 private $thrownErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED
88 private $scopedErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED 88 private $scopedErrors = 0x1FFF; // E_ALL - E_DEPRECATED - E_USER_DEPRECATED
89 private $tracedErrors = 0x77FB; // E_ALL - E_STRICT - E_PARSE 89 private $tracedErrors = 0x77FB; // E_ALL - E_STRICT - E_PARSE
90 private $screamedErrors = 0x55; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE 90 private $screamedErrors = 0x55; // E_ERROR + E_CORE_ERROR + E_COMPILE_ERROR + E_PARSE
95 private $isRoot = false; 95 private $isRoot = false;
96 private $exceptionHandler; 96 private $exceptionHandler;
97 private $bootstrappingLogger; 97 private $bootstrappingLogger;
98 98
99 private static $reservedMemory; 99 private static $reservedMemory;
100 private static $stackedErrors = array(); 100 private static $stackedErrors = [];
101 private static $stackedErrorLevels = array(); 101 private static $stackedErrorLevels = [];
102 private static $toStringException = null; 102 private static $toStringException = null;
103 private static $silencedErrorCache = array(); 103 private static $silencedErrorCache = [];
104 private static $silencedErrorCount = 0; 104 private static $silencedErrorCount = 0;
105 private static $exitCode = 0; 105 private static $exitCode = 0;
106 106
107 /** 107 /**
108 * Registers the error handler. 108 * Registers the error handler.
121 121
122 if ($handlerIsNew = null === $handler) { 122 if ($handlerIsNew = null === $handler) {
123 $handler = new static(); 123 $handler = new static();
124 } 124 }
125 125
126 if (null === $prev = set_error_handler(array($handler, 'handleError'))) { 126 if (null === $prev = set_error_handler([$handler, 'handleError'])) {
127 restore_error_handler(); 127 restore_error_handler();
128 // Specifying the error types earlier would expose us to https://bugs.php.net/63206 128 // Specifying the error types earlier would expose us to https://bugs.php.net/63206
129 set_error_handler(array($handler, 'handleError'), $handler->thrownErrors | $handler->loggedErrors); 129 set_error_handler([$handler, 'handleError'], $handler->thrownErrors | $handler->loggedErrors);
130 $handler->isRoot = true; 130 $handler->isRoot = true;
131 } 131 }
132 132
133 if ($handlerIsNew && is_array($prev) && $prev[0] instanceof self) { 133 if ($handlerIsNew && \is_array($prev) && $prev[0] instanceof self) {
134 $handler = $prev[0]; 134 $handler = $prev[0];
135 $replace = false; 135 $replace = false;
136 } 136 }
137 if (!$replace && $prev) { 137 if (!$replace && $prev) {
138 restore_error_handler(); 138 restore_error_handler();
139 $handlerIsRegistered = is_array($prev) && $handler === $prev[0]; 139 $handlerIsRegistered = \is_array($prev) && $handler === $prev[0];
140 } else { 140 } else {
141 $handlerIsRegistered = true; 141 $handlerIsRegistered = true;
142 } 142 }
143 if (is_array($prev = set_exception_handler(array($handler, 'handleException'))) && $prev[0] instanceof self) { 143 if (\is_array($prev = set_exception_handler([$handler, 'handleException'])) && $prev[0] instanceof self) {
144 restore_exception_handler(); 144 restore_exception_handler();
145 if (!$handlerIsRegistered) { 145 if (!$handlerIsRegistered) {
146 $handler = $prev[0]; 146 $handler = $prev[0];
147 } elseif ($handler !== $prev[0] && $replace) { 147 } elseif ($handler !== $prev[0] && $replace) {
148 set_exception_handler(array($handler, 'handleException')); 148 set_exception_handler([$handler, 'handleException']);
149 $p = $prev[0]->setExceptionHandler(null); 149 $p = $prev[0]->setExceptionHandler(null);
150 $handler->setExceptionHandler($p); 150 $handler->setExceptionHandler($p);
151 $prev[0]->setExceptionHandler($p); 151 $prev[0]->setExceptionHandler($p);
152 } 152 }
153 } else { 153 } else {
176 * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants 176 * @param array|int $levels An array map of E_* to LogLevel::* or an integer bit field of E_* constants
177 * @param bool $replace Whether to replace or not any existing logger 177 * @param bool $replace Whether to replace or not any existing logger
178 */ 178 */
179 public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $replace = false) 179 public function setDefaultLogger(LoggerInterface $logger, $levels = E_ALL, $replace = false)
180 { 180 {
181 $loggers = array(); 181 $loggers = [];
182 182
183 if (is_array($levels)) { 183 if (\is_array($levels)) {
184 foreach ($levels as $type => $logLevel) { 184 foreach ($levels as $type => $logLevel) {
185 if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) { 185 if (empty($this->loggers[$type][0]) || $replace || $this->loggers[$type][0] === $this->bootstrappingLogger) {
186 $loggers[$type] = array($logger, $logLevel); 186 $loggers[$type] = [$logger, $logLevel];
187 } 187 }
188 } 188 }
189 } else { 189 } else {
190 if (null === $levels) { 190 if (null === $levels) {
191 $levels = E_ALL; 191 $levels = E_ALL;
212 */ 212 */
213 public function setLoggers(array $loggers) 213 public function setLoggers(array $loggers)
214 { 214 {
215 $prevLogged = $this->loggedErrors; 215 $prevLogged = $this->loggedErrors;
216 $prev = $this->loggers; 216 $prev = $this->loggers;
217 $flush = array(); 217 $flush = [];
218 218
219 foreach ($loggers as $type => $log) { 219 foreach ($loggers as $type => $log) {
220 if (!isset($prev[$type])) { 220 if (!isset($prev[$type])) {
221 throw new \InvalidArgumentException('Unknown error type: '.$type); 221 throw new \InvalidArgumentException('Unknown error type: '.$type);
222 } 222 }
223 if (!is_array($log)) { 223 if (!\is_array($log)) {
224 $log = array($log); 224 $log = [$log];
225 } elseif (!array_key_exists(0, $log)) { 225 } elseif (!array_key_exists(0, $log)) {
226 throw new \InvalidArgumentException('No logger provided'); 226 throw new \InvalidArgumentException('No logger provided');
227 } 227 }
228 if (null === $log[0]) { 228 if (null === $log[0]) {
229 $this->loggedErrors &= ~$type; 229 $this->loggedErrors &= ~$type;
351 */ 351 */
352 private function reRegister($prev) 352 private function reRegister($prev)
353 { 353 {
354 if ($prev !== $this->thrownErrors | $this->loggedErrors) { 354 if ($prev !== $this->thrownErrors | $this->loggedErrors) {
355 $handler = set_error_handler('var_dump'); 355 $handler = set_error_handler('var_dump');
356 $handler = is_array($handler) ? $handler[0] : null; 356 $handler = \is_array($handler) ? $handler[0] : null;
357 restore_error_handler(); 357 restore_error_handler();
358 if ($handler === $this) { 358 if ($handler === $this) {
359 restore_error_handler(); 359 restore_error_handler();
360 if ($this->isRoot) { 360 if ($this->isRoot) {
361 set_error_handler(array($this, 'handleError'), $this->thrownErrors | $this->loggedErrors); 361 set_error_handler([$this, 'handleError'], $this->thrownErrors | $this->loggedErrors);
362 } else { 362 } else {
363 set_error_handler(array($this, 'handleError')); 363 set_error_handler([$this, 'handleError']);
364 } 364 }
365 } 365 }
366 } 366 }
367 } 367 }
368 368
394 if (!$type || (!$log && !$throw)) { 394 if (!$type || (!$log && !$throw)) {
395 return !$silenced && $type && $log; 395 return !$silenced && $type && $log;
396 } 396 }
397 $scope = $this->scopedErrors & $type; 397 $scope = $this->scopedErrors & $type;
398 398
399 if (4 < $numArgs = func_num_args()) { 399 if (4 < $numArgs = \func_num_args()) {
400 $context = $scope ? (func_get_arg(4) ?: array()) : array(); 400 $context = $scope ? (func_get_arg(4) ?: []) : [];
401 $backtrace = 5 < $numArgs ? func_get_arg(5) : null; // defined on HHVM 401 $backtrace = 5 < $numArgs ? func_get_arg(5) : null; // defined on HHVM
402 } else { 402 } else {
403 $context = array(); 403 $context = [];
404 $backtrace = null; 404 $backtrace = null;
405 } 405 }
406 406
407 if (isset($context['GLOBALS']) && $scope) { 407 if (isset($context['GLOBALS']) && $scope) {
408 $e = $context; // Whatever the signature of the method, 408 $e = $context; // Whatever the signature of the method,
424 if (null !== self::$toStringException) { 424 if (null !== self::$toStringException) {
425 $errorAsException = self::$toStringException; 425 $errorAsException = self::$toStringException;
426 self::$toStringException = null; 426 self::$toStringException = null;
427 } elseif (!$throw && !($type & $level)) { 427 } elseif (!$throw && !($type & $level)) {
428 if (!isset(self::$silencedErrorCache[$id = $file.':'.$line])) { 428 if (!isset(self::$silencedErrorCache[$id = $file.':'.$line])) {
429 $lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3), $type, $file, $line, false) : array(); 429 $lightTrace = $this->tracedErrors & $type ? $this->cleanTrace(debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3), $type, $file, $line, false) : [];
430 $errorAsException = new SilencedErrorContext($type, $file, $line, $lightTrace); 430 $errorAsException = new SilencedErrorContext($type, $file, $line, $lightTrace);
431 } elseif (isset(self::$silencedErrorCache[$id][$message])) { 431 } elseif (isset(self::$silencedErrorCache[$id][$message])) {
432 $lightTrace = null; 432 $lightTrace = null;
433 $errorAsException = self::$silencedErrorCache[$id][$message]; 433 $errorAsException = self::$silencedErrorCache[$id][$message];
434 ++$errorAsException->count; 434 ++$errorAsException->count;
435 } else { 435 } else {
436 $lightTrace = array(); 436 $lightTrace = [];
437 $errorAsException = null; 437 $errorAsException = null;
438 } 438 }
439 439
440 if (100 < ++self::$silencedErrorCount) { 440 if (100 < ++self::$silencedErrorCount) {
441 self::$silencedErrorCache = $lightTrace = array(); 441 self::$silencedErrorCache = $lightTrace = [];
442 self::$silencedErrorCount = 1; 442 self::$silencedErrorCount = 1;
443 } 443 }
444 if ($errorAsException) { 444 if ($errorAsException) {
445 self::$silencedErrorCache[$id][$message] = $errorAsException; 445 self::$silencedErrorCache[$id][$message] = $errorAsException;
446 } 446 }
458 if ($throw || $this->tracedErrors & $type) { 458 if ($throw || $this->tracedErrors & $type) {
459 $backtrace = $backtrace ?: $errorAsException->getTrace(); 459 $backtrace = $backtrace ?: $errorAsException->getTrace();
460 $lightTrace = $this->cleanTrace($backtrace, $type, $file, $line, $throw); 460 $lightTrace = $this->cleanTrace($backtrace, $type, $file, $line, $throw);
461 $this->traceReflector->setValue($errorAsException, $lightTrace); 461 $this->traceReflector->setValue($errorAsException, $lightTrace);
462 } else { 462 } else {
463 $this->traceReflector->setValue($errorAsException, array()); 463 $this->traceReflector->setValue($errorAsException, []);
464 } 464 }
465 } 465 }
466 466
467 if ($throw) { 467 if ($throw) {
468 if (E_USER_ERROR & $type) { 468 if (E_USER_ERROR & $type) {
508 } 508 }
509 509
510 if ($this->isRecursive) { 510 if ($this->isRecursive) {
511 $log = 0; 511 $log = 0;
512 } elseif (self::$stackedErrorLevels) { 512 } elseif (self::$stackedErrorLevels) {
513 self::$stackedErrors[] = array( 513 self::$stackedErrors[] = [
514 $this->loggers[$type][0], 514 $this->loggers[$type][0],
515 ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG, 515 ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG,
516 $logMessage, 516 $logMessage,
517 $errorAsException ? array('exception' => $errorAsException) : array(), 517 $errorAsException ? ['exception' => $errorAsException] : [],
518 ); 518 ];
519 } else { 519 } else {
520 try { 520 try {
521 $this->isRecursive = true; 521 $this->isRecursive = true;
522 $level = ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG; 522 $level = ($type & $level) ? $this->loggers[$type][1] : LogLevel::DEBUG;
523 $this->loggers[$type][0]->log($level, $logMessage, $errorAsException ? array('exception' => $errorAsException) : array()); 523 $this->loggers[$type][0]->log($level, $logMessage, $errorAsException ? ['exception' => $errorAsException] : []);
524 } finally { 524 } finally {
525 $this->isRecursive = false; 525 $this->isRecursive = false;
526
527 if (!\defined('HHVM_VERSION')) {
528 set_error_handler([$this, __FUNCTION__]);
529 }
526 } 530 }
527 } 531 }
528 532
529 return !$silenced && $type && $log; 533 return !$silenced && $type && $log;
530 } 534 }
549 $handlerException = null; 553 $handlerException = null;
550 554
551 if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) { 555 if (($this->loggedErrors & $type) || $exception instanceof FatalThrowableError) {
552 if ($exception instanceof FatalErrorException) { 556 if ($exception instanceof FatalErrorException) {
553 if ($exception instanceof FatalThrowableError) { 557 if ($exception instanceof FatalThrowableError) {
554 $error = array( 558 $error = [
555 'type' => $type, 559 'type' => $type,
556 'message' => $message = $exception->getMessage(), 560 'message' => $message = $exception->getMessage(),
557 'file' => $exception->getFile(), 561 'file' => $exception->getFile(),
558 'line' => $exception->getLine(), 562 'line' => $exception->getLine(),
559 ); 563 ];
560 } else { 564 } else {
561 $message = 'Fatal '.$exception->getMessage(); 565 $message = 'Fatal '.$exception->getMessage();
562 } 566 }
563 } elseif ($exception instanceof \ErrorException) { 567 } elseif ($exception instanceof \ErrorException) {
564 $message = 'Uncaught '.$exception->getMessage(); 568 $message = 'Uncaught '.$exception->getMessage();
566 $message = 'Uncaught Exception: '.$exception->getMessage(); 570 $message = 'Uncaught Exception: '.$exception->getMessage();
567 } 571 }
568 } 572 }
569 if ($this->loggedErrors & $type) { 573 if ($this->loggedErrors & $type) {
570 try { 574 try {
571 $this->loggers[$type][0]->log($this->loggers[$type][1], $message, array('exception' => $exception)); 575 $this->loggers[$type][0]->log($this->loggers[$type][1], $message, ['exception' => $exception]);
572 } catch (\Exception $handlerException) { 576 } catch (\Exception $handlerException) {
573 } catch (\Throwable $handlerException) { 577 } catch (\Throwable $handlerException) {
574 } 578 }
575 } 579 }
576 if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) { 580 if ($exception instanceof FatalErrorException && !$exception instanceof OutOfMemoryException && $error) {
610 if (null === self::$reservedMemory) { 614 if (null === self::$reservedMemory) {
611 return; 615 return;
612 } 616 }
613 617
614 $handler = self::$reservedMemory = null; 618 $handler = self::$reservedMemory = null;
615 $handlers = array(); 619 $handlers = [];
616 $previousHandler = null; 620 $previousHandler = null;
617 $sameHandlerLimit = 10; 621 $sameHandlerLimit = 10;
618 622
619 while (!is_array($handler) || !$handler[0] instanceof self) { 623 while (!\is_array($handler) || !$handler[0] instanceof self) {
620 $handler = set_exception_handler('var_dump'); 624 $handler = set_exception_handler('var_dump');
621 restore_exception_handler(); 625 restore_exception_handler();
622 626
623 if (!$handler) { 627 if (!$handler) {
624 break; 628 break;
641 } 645 }
642 if ($handler !== $h) { 646 if ($handler !== $h) {
643 $handler[0]->setExceptionHandler($h); 647 $handler[0]->setExceptionHandler($h);
644 } 648 }
645 $handler = $handler[0]; 649 $handler = $handler[0];
646 $handlers = array(); 650 $handlers = [];
647 651
648 if ($exit = null === $error) { 652 if ($exit = null === $error) {
649 $error = error_get_last(); 653 $error = error_get_last();
650 } 654 }
651 655
725 } 729 }
726 } 730 }
727 731
728 if (empty(self::$stackedErrorLevels)) { 732 if (empty(self::$stackedErrorLevels)) {
729 $errors = self::$stackedErrors; 733 $errors = self::$stackedErrors;
730 self::$stackedErrors = array(); 734 self::$stackedErrors = [];
731 735
732 foreach ($errors as $error) { 736 foreach ($errors as $error) {
733 $error[0]->log($error[1], $error[2], $error[3]); 737 $error[0]->log($error[1], $error[2], $error[3]);
734 } 738 }
735 } 739 }
742 * 746 *
743 * @return FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface 747 * @return FatalErrorHandlerInterface[] An array of FatalErrorHandlerInterface
744 */ 748 */
745 protected function getFatalErrorHandlers() 749 protected function getFatalErrorHandlers()
746 { 750 {
747 return array( 751 return [
748 new UndefinedFunctionFatalErrorHandler(), 752 new UndefinedFunctionFatalErrorHandler(),
749 new UndefinedMethodFatalErrorHandler(), 753 new UndefinedMethodFatalErrorHandler(),
750 new ClassNotFoundFatalErrorHandler(), 754 new ClassNotFoundFatalErrorHandler(),
751 ); 755 ];
752 } 756 }
753 757
754 private function cleanTrace($backtrace, $type, $file, $line, $throw) 758 private function cleanTrace($backtrace, $type, $file, $line, $throw)
755 { 759 {
756 $lightTrace = $backtrace; 760 $lightTrace = $backtrace;
757 761
758 for ($i = 0; isset($backtrace[$i]); ++$i) { 762 for ($i = 0; isset($backtrace[$i]); ++$i) {
759 if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) { 763 if (isset($backtrace[$i]['file'], $backtrace[$i]['line']) && $backtrace[$i]['line'] === $line && $backtrace[$i]['file'] === $file) {
760 $lightTrace = array_slice($lightTrace, 1 + $i); 764 $lightTrace = \array_slice($lightTrace, 1 + $i);
761 break; 765 break;
762 } 766 }
763 } 767 }
764 if (!($throw || $this->scopedErrors & $type)) { 768 if (!($throw || $this->scopedErrors & $type)) {
765 for ($i = 0; isset($lightTrace[$i]); ++$i) { 769 for ($i = 0; isset($lightTrace[$i]); ++$i) {