From 0652f2a0777bea373b1572f0defff8dc087427f8 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Mon, 16 Dec 2024 19:39:09 +0800 Subject: [PATCH] refactor: add `@throws RedirectException` in `Controller::initController()` --- system/Controller.php | 3 +++ utils/phpstan-baseline/catch.neverThrown.neon | 8 -------- utils/phpstan-baseline/loader.neon | 1 - 3 files changed, 3 insertions(+), 9 deletions(-) delete mode 100644 utils/phpstan-baseline/catch.neverThrown.neon diff --git a/system/Controller.php b/system/Controller.php index fc0c41bf18fa..c686a48b7739 100644 --- a/system/Controller.php +++ b/system/Controller.php @@ -15,6 +15,7 @@ use CodeIgniter\HTTP\CLIRequest; use CodeIgniter\HTTP\Exceptions\HTTPException; +use CodeIgniter\HTTP\Exceptions\RedirectException; use CodeIgniter\HTTP\IncomingRequest; use CodeIgniter\HTTP\RequestInterface; use CodeIgniter\HTTP\ResponseInterface; @@ -78,6 +79,7 @@ class Controller * @return void * * @throws HTTPException + * @throws RedirectException */ public function initController(RequestInterface $request, ResponseInterface $response, LoggerInterface $logger) { @@ -106,6 +108,7 @@ public function initController(RequestInterface $request, ResponseInterface $res * @return void * * @throws HTTPException + * @throws RedirectException */ protected function forceHTTPS(int $duration = 31_536_000) { diff --git a/utils/phpstan-baseline/catch.neverThrown.neon b/utils/phpstan-baseline/catch.neverThrown.neon deleted file mode 100644 index 1d590a78fac2..000000000000 --- a/utils/phpstan-baseline/catch.neverThrown.neon +++ /dev/null @@ -1,8 +0,0 @@ -# total 1 error - -parameters: - ignoreErrors: - - - message: '#^Dead catch \- CodeIgniter\\HTTP\\Exceptions\\RedirectException is never thrown in the try block\.$#' - count: 1 - path: ../../tests/system/ControllerTest.php diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index a0e8208d48a7..40d901a7ab2d 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -7,7 +7,6 @@ includes: - booleanNot.exprNotBoolean.neon - booleanOr.leftNotBoolean.neon - booleanOr.rightNotBoolean.neon - - catch.neverThrown.neon - class.notFound.neon - codeigniter.cacheHandlerInstance.neon - codeigniter.configArgumentInstanceof.neon