Skip to content

Commit

Permalink
Renamed ErrorHandler methods
Browse files Browse the repository at this point in the history
  • Loading branch information
freost committed Oct 21, 2024
1 parent 5afb991 commit a3c165e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion src/mako/application/services/cli/ErrorHandlerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/mako/application/services/web/ErrorHandlerService.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
12 changes: 6 additions & 6 deletions src/mako/error/ErrorHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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(...));
}

/**
Expand Down Expand Up @@ -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]);
}
Expand All @@ -206,7 +206,7 @@ public function replaceHandlers(string $exceptionType, Closure $handler): void
{
$this->clearHandlers($exceptionType);

$this->handle($exceptionType, $handler);
$this->addHandler($exceptionType, $handler);
}

/**
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit a3c165e

Please sign in to comment.