public static function ErrorHandler::register in Zircon Profile 8
Same name and namespace in other branches
- 8.0 vendor/symfony/debug/ErrorHandler.php \Symfony\Component\Debug\ErrorHandler::register()
Registers the error handler.
Parameters
self|null|int $handler The handler to register, or @deprecated (since version 2.6, to be removed in 3.0) bit field of thrown levels:
bool $replace Whether to replace or not any existing handler:
Return value
self The registered error handler
12 calls to ErrorHandler::register()
- Debug::enable in vendor/
symfony/ debug/ Debug.php - Enables the debug tools.
- DebugClassLoaderTest::testStacking in vendor/
symfony/ debug/ Tests/ DebugClassLoaderTest.php - ErrorHandlerTest::testConstruct in vendor/
symfony/ debug/ Tests/ ErrorHandlerTest.php - ErrorHandlerTest::testDefaultLogger in vendor/
symfony/ debug/ Tests/ ErrorHandlerTest.php - ErrorHandlerTest::testErrorStacking in vendor/
symfony/ debug/ Tests/ ErrorHandlerTest.php
File
- vendor/
symfony/ debug/ ErrorHandler.php, line 119
Class
- ErrorHandler
- A generic ErrorHandler for the PHP engine.
Namespace
Symfony\Component\DebugCode
public static function register($handler = null, $replace = true) {
if (null === self::$reservedMemory) {
self::$reservedMemory = str_repeat('x', 10240);
register_shutdown_function(__CLASS__ . '::handleFatalError');
}
$levels = -1;
if ($handlerIsNew = !$handler instanceof self) {
// @deprecated polymorphism, to be removed in 3.0
if (null !== $handler) {
$levels = $replace ? $handler : 0;
$replace = true;
}
$handler = new static();
}
$prev = set_error_handler(array(
$handler,
'handleError',
), $handler->thrownErrors | $handler->loggedErrors);
if ($handlerIsNew && is_array($prev) && $prev[0] instanceof self) {
$handler = $prev[0];
$replace = false;
}
if ($replace || !$prev) {
$handler
->setExceptionHandler(set_exception_handler(array(
$handler,
'handleException',
)));
}
else {
restore_error_handler();
}
$handler
->throwAt($levels & $handler->thrownErrors, true);
return $handler;
}