/** * Exception Handler Callback * Rethrows uncatched Exceptions in our presentation style. * * @see http://php.net/manual/de/function.set-exception-handler.php * * @param $exception PHP Exception Objects are valid (Type Hint). */ public function handle(\Exception $exception) { if ($exception->getCode() > 0) { self::fetchExceptionTemplates($exception->getCode()); } echo YellowScreenOfDeath::renderException($exception->getMessage(), $exception->getTraceAsString(), $exception->getCode(), $exception->getFile(), $exception->getLine(), $exception->getTrace()); // we use our own exception handler here, so PHP returns exit code 0. // the execution will stop anyway, but let's return the correct code. \Koch\Tools\ApplicationQuit::quit(255); }
/** * Displays the content of a variable with var_dump. * The content gets escaping and pre tags are applied for better readability. * * @param mixed $var The variable to debug. * @param bool $exit Stop execution after dump? Default is true (stops). */ public static function dump($var, $exit = true) { // var_dump the content into a buffer and store it to variable ob_start(); var_dump($var); $var_dump = ob_get_clean(); /* * if xdebug is on and overloaded the var_dump function, * then the output is already properly escaped and prepared for direct output. * if xdebug is off, we need to apply escaping ourself. * html pre tags are applied to structure the display a bit more. */ if (false === extension_loaded('xdebug')) { $var_dump = preg_replace('/\\]\\=\\>\\n(\\s+)/m', '] => ', $var_dump); $var_dump = '<pre>' . htmlspecialchars($var_dump, ENT_QUOTES, 'UTF-8') . '</pre>'; } // display where this debug statement echo self::getOriginOfDebugCall(); // output the content of the buffer echo $var_dump; // do not exit, if we are inside a test run if (defined('UNIT_TEST_RUN') === false or UNIT_TEST_RUN === false) { if ($exit === true) { \Koch\Tools\ApplicationQuit::quit(); } } }