file = $file; $this->line = $line; $this->_trace = $trace; parent::__construct($message, $code); return; } /** * Enable error handler: Transform PHP error into `\Hoa\Exception\Error`. * * @param bool $enable Enable. * @return mixed */ public static function enableErrorHandler($enable = true) { if (false === $enable) { return restore_error_handler(); } return set_error_handler( function ($no, $str, $file = null, $line = null, $ctx = null) { if (0 === ($no & error_reporting())) { return; } $trace = debug_backtrace(); array_shift($trace); array_shift($trace); throw new Error($str, $no, $file, $line, $trace); } ); } }