Beispiel #1
0
 /**
  * Handle a PHP error
  *
  * @param int         $code    error code
  * @param string      $message message
  * @param string|null $file    file name
  * @param int|null    $line    line number
  * @param array       $context variable context
  * @return bool
  */
 public function onError($code, $message, $file = null, $line = null, array $context = null)
 {
     $this->lastError = error_get_last();
     $this->currentError = null !== $context ? new ContextualErrorException($message, 0, $code, $file, $line, null, $context) : new \ErrorException($message, 0, $code, $file, $line);
     $suppressed = 0 === ($code & error_reporting());
     if ($this->hasListeners('error')) {
         // make sure autoloading is active before emitting an event
         // (autoloading is inactive in some PHP versions during compile-time errors)
         // (the bug appears to have been fixed in PHP 5.4.21+, 5.5.5+ and 5.6.0+)
         // https://bugs.php.net/42098
         if (PHP_MAJOR_VERSION > 5 || PHP_MINOR_VERSION >= 6 || PHP_MINOR_VERSION === 5 && PHP_RELEASE_VERSION >= 5 || PHP_MINOR_VERSION === 4 && PHP_RELEASE_VERSION >= 21 || Debug::isAutoloadingActive()) {
             $e = null;
             try {
                 $this->emitArray('error', array($this->currentError, $this->debug, &$suppressed));
             } catch (\Exception $e) {
             } catch (\Throwable $e) {
             }
             if (null !== $e) {
                 $this->currentError = Debug::joinExceptionChains($this->currentError, $e);
                 $suppressed = false;
             }
         }
     }
     if (!$suppressed) {
         $error = $this->currentError;
         $this->currentError = null;
         throw $error;
     } else {
         return true;
     }
 }