From a3c165ec6ce2954726fda436362bfac12d5c3990 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frederic=20G=2E=20=C3=98stby?= Date: Mon, 21 Oct 2024 20:20:27 +0200 Subject: [PATCH] Renamed ErrorHandler methods --- CHANGELOG.md | 4 +++- .../application/services/cli/ErrorHandlerService.php | 2 +- .../application/services/web/ErrorHandlerService.php | 2 +- src/mako/error/ErrorHandler.php | 12 ++++++------ 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 069bf55c5..acc821c29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -34,9 +34,11 @@ The major version bump is due to upping the required PHP version from `8.1` to ` * Added `Redis::executeCommand()` helper method that makes it possible to call commands not yet supported by the client. #### Changes -* The `UUID::sequential()` method has been renamed to `UUID::v4Sequential()`. * The gatekeeper `Session::login()` and `Session::forceLogin()` methods will now return a `LoginStatus` enum instance instead of a mix of boolean and integer values. * Dropped support for underscore speparated Redis method calls. +* Renamed the `UUID::sequential()` method to `UUID::v4Sequential()`. +* Renamed the `ErrorHandler::handle()` method to `ErrorHandler::addHandler()`. +* Renamed the `ErrorHandler::handler()` method to `ErrorHandler::handle()`. #### Improvements diff --git a/src/mako/application/services/cli/ErrorHandlerService.php b/src/mako/application/services/cli/ErrorHandlerService.php index 82457cd83..d2a73c8be 100644 --- a/src/mako/application/services/cli/ErrorHandlerService.php +++ b/src/mako/application/services/cli/ErrorHandlerService.php @@ -36,7 +36,7 @@ public function register(): void } } - $errorHandler->handle(Throwable::class, $config['display_errors'] ? DevelopmentHandler::class : ProductionHandler::class); + $errorHandler->addHandler(Throwable::class, $config['display_errors'] ? DevelopmentHandler::class : ProductionHandler::class); $this->container->registerInstance([ErrorHandler::class, 'errorHandler'], $errorHandler); } diff --git a/src/mako/application/services/web/ErrorHandlerService.php b/src/mako/application/services/web/ErrorHandlerService.php index 6a75c531b..5b13c8fb1 100644 --- a/src/mako/application/services/web/ErrorHandlerService.php +++ b/src/mako/application/services/web/ErrorHandlerService.php @@ -36,7 +36,7 @@ public function register(): void } } - $errorHandler->handle(Throwable::class, $config['display_errors'] ? DevelopmentHandler::class : ProductionHandler::class, ['keep' => $config['keep'] ?? []]); + $errorHandler->addHandler(Throwable::class, $config['display_errors'] ? DevelopmentHandler::class : ProductionHandler::class, ['keep' => $config['keep'] ?? []]); $this->container->registerInstance([ErrorHandler::class, 'errorHandler'], $errorHandler); } diff --git a/src/mako/error/ErrorHandler.php b/src/mako/error/ErrorHandler.php index e8751ffa2..9ae5117f9 100644 --- a/src/mako/error/ErrorHandler.php +++ b/src/mako/error/ErrorHandler.php @@ -72,7 +72,7 @@ public function __construct( ) { // Add a basic exception handler to the stack - $this->handle(Throwable::class, $this->getFallbackHandler()); + $this->addHandler(Throwable::class, $this->getFallbackHandler()); // Registers the exception handler @@ -134,13 +134,13 @@ protected function register(): void $e = error_get_last(); if ($e !== null && (error_reporting() & $e['type']) !== 0 && !$this->disableShutdownHandler) { - $this->handler(new ErrorException($e['message'], code: $e['type'], filename: $e['file'], line: $e['line'])); + $this->handle(new ErrorException($e['message'], code: $e['type'], filename: $e['file'], line: $e['line'])); } }); // Set the exception handler - set_exception_handler($this->handler(...)); + set_exception_handler($this->handle(...)); } /** @@ -182,7 +182,7 @@ public function disableShutdownHandler(): void /** * Prepends an exception handler to the stack. */ - public function handle(string $exceptionType, Closure|string $handler, array $parameters = []): void + public function addHandler(string $exceptionType, Closure|string $handler, array $parameters = []): void { array_unshift($this->handlers, ['exceptionType' => $exceptionType, 'handler' => $handler, 'parameters' => $parameters]); } @@ -206,7 +206,7 @@ public function replaceHandlers(string $exceptionType, Closure $handler): void { $this->clearHandlers($exceptionType); - $this->handle($exceptionType, $handler); + $this->addHandler($exceptionType, $handler); } /** @@ -285,7 +285,7 @@ protected function logException(Throwable $exception): void /** * Handles uncaught exceptions. */ - public function handler(Throwable $exception, bool $shouldExit = true): void + public function handle(Throwable $exception, bool $shouldExit = true): void { try { // Empty output buffers