Esempio n. 1
0
 public function testGetInstance()
 {
     $error = \r8\Error::getInstance();
     $this->assertThat($error, $this->isInstanceOf('\\r8\\Error'));
     $this->assertSame($error, \r8\Error::getInstance());
     $this->assertSame($error, \r8\Error::getInstance());
 }
Esempio n. 2
0
 */
\r8\Autoload::getInstance()->register('r8', r8_DIR_CLASSES)->register('r8\\iface', r8_DIR_INTERFACES)->register('r8\\Test', r8_DIR_TEST);
spl_autoload_register(array(\r8\Autoload::getInstance(), "load"));
/**
 * Take a snapshot of the environment
 */
\r8\Env::Request();
/**
 * Set up error handling, but only if it isn't being suppressed by the including code
 */
if (!defined("r8_SUPPRESS_HANDLERS")) {
    // Register the error handler
    set_error_handler(function ($code, $message, $file, $line) {
        $level = (int) ini_get('error_reporting');
        $code = (int) $code;
        if (!($code & $level)) {
            return TRUE;
        }
        $backtrace = \r8\Backtrace::create()->popEvent();
        \r8\Error::getInstance()->handle(new \r8\Error\PHP($file, $line, $code, $message, $backtrace));
    });
    // Register an exception handler
    set_exception_handler(function ($exception) {
        \r8\Error::getInstance()->handle(new \r8\Error\Exception($exception));
    });
    // Hook in the error handler to the error log
    \r8\Error::getInstance()->register(new \r8\Error\Handler\Stream(new \r8\Error\Formatter\JSON(\r8\Env::request()), new \r8\Stream\Out\ErrorLog()));
    // Hook in the error handler to output the error to the client
    \r8\Error::getInstance()->register(new \r8\Error\Handler\IniDisplay(new \r8\Error\Handler\Stream(\r8\Env::request()->isCLI() ? new \r8\Error\Formatter\Text(\r8\Env::request()) : new \r8\Error\Formatter\HTML(\r8\Env::request()), new \r8\Stream\Out\StdOut())));
}
// @codeCoverageIgnoreEnd