From e4cf9edc1cf396ea423c560467af5259302e6d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20D?= Date: Fri, 1 Dec 2023 05:53:35 +0100 Subject: [PATCH] chore: Improve bootstrapping MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Rubén D --- lib/SP/Core/Bootstrap/BootstrapBase.php | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/lib/SP/Core/Bootstrap/BootstrapBase.php b/lib/SP/Core/Bootstrap/BootstrapBase.php index 4458d43b..b24d82cc 100644 --- a/lib/SP/Core/Bootstrap/BootstrapBase.php +++ b/lib/SP/Core/Bootstrap/BootstrapBase.php @@ -107,15 +107,13 @@ abstract class BootstrapBase implements BootstrapInterface private function initRouter(): void { - $this->router->onError(function ($router, $err_msg, $type, $err) { - logger('Routing error: ' . $err_msg); - - /** @var Exception|Throwable $err */ - logger('Routing error: ' . $err->getTraceAsString()); - - /** @var Klein $router */ - $router->response()->body(__($err_msg)); - }); + $this->router->onError( + static function (Klein $router, string $err_msg, string $type, Exception|Throwable $err): void { + logger(sprintf('Routing error: %s', $err_msg)); + logger(sprintf('Routing error: %s', $err->getTraceAsString())); + $router->response()->body(__($err_msg)); + } + ); // Manage requests for options $this->router->respond('OPTIONS', null, $this->manageCorsRequest()); @@ -302,9 +300,8 @@ abstract class BootstrapBase implements BootstrapInterface } /** - * @param string $class - * - * @return object + * @deprecated + * FIXME: delete */ final protected function createObjectFor(string $class): object {