chainedErrorHandler; } /** * Get the types of errors that will be logged * * @return int Binary set of E_* constants */ public function getLoggedErrorTypes() { return $this->logErrorTypes; } /** * Log these types of errors or exceptions * * @param int $type E_* contants as binary set */ protected function logUncaughtErrors($type) { $this->logErrorTypes |= $type; $unhandled = E_ERROR | E_PARSE | E_CORE_ERROR | E_COMPILE_ERROR; if ($type & ~$unhandled) { $this->initErrorHandler(); } if ($type & $unhandled) { $this->initShutdownFunction(); } } /** * Use the global error handler to convert E_USER_ERROR and E_RECOVERABLE_ERROR to an ErrorException */ public function converErrorsToExceptions() { $this->convertFatalErrors = true; $this->initErrorHandler(); } /** * Use the global error handler */ protected function initErrorHandler() { if (!isset($this->chainedErrorHandler)) { $this->chainedErrorHandler = $this->setErrorHandler([$this, 'handleError']) ?: false; } } /** * Uncaught error handler * @ignore * * @param int $type * @param string $message * @param string $file * @param int $line * @param array $context */ public function handleError($type, $message, $file, $line, $context) { if ($this->errorReporting() & $type) { $error = new \ErrorException($message, 0, $type, $file, $line); if ($this->convertFatalErrors && ($type & (E_RECOVERABLE_ERROR | E_USER_ERROR))) { throw $error; } if ($this->getLoggedErrorTypes() & $type) { $this->log($error); } } return $this->chainedErrorHandler ? call_user_func($this->chainedErrorHandler, $type, $message, $file, $line, $context) : false; } }