From ee0580f6df357682bb64caf10409eac4a88c6517 Mon Sep 17 00:00:00 2001 From: Aselsan Date: Mon, 14 Apr 2025 05:49:40 +0700 Subject: [PATCH 1/4] Fix nullCoalesce.variable errors. rm nullCoalesce.variable.neon Update error count Restore missing nullCoalesce.variable.neon file Update loader.neon and remove obsolete nullCoalesce.variable.neon Use type checking instead of null coalescing Prevent superglobals from being changed by users chore: suppress PHPStan warning for and --- system/HTTP/RedirectResponse.php | 10 ++++++++-- utils/phpstan-baseline/loader.neon | 1 - utils/phpstan-baseline/nullCoalesce.variable.neon | 13 ------------- 3 files changed, 8 insertions(+), 16 deletions(-) delete mode 100644 utils/phpstan-baseline/nullCoalesce.variable.neon diff --git a/system/HTTP/RedirectResponse.php b/system/HTTP/RedirectResponse.php index 206b1de07c67..4fb1fddb97cd 100644 --- a/system/HTTP/RedirectResponse.php +++ b/system/HTTP/RedirectResponse.php @@ -92,9 +92,15 @@ public function back(?int $code = null, string $method = 'auto') public function withInput() { $session = service('session'); + + // @phpstan-ignore-next-line + $get = $_GET ?? []; + // @phpstan-ignore-next-line + $post = $_POST ?? []; + $session->setFlashdata('_ci_old_input', [ - 'get' => $_GET ?? [], - 'post' => $_POST ?? [], + 'get' => $get, + 'post' => $post, ]); $this->withErrors(); diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 659f4a2858d1..f2c97f4bb57b 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -22,7 +22,6 @@ includes: - missingType.return.neon - notIdentical.alwaysTrue.neon - nullCoalesce.property.neon - - nullCoalesce.variable.neon - offsetAccess.notFound.neon - property.defaultValue.neon - property.nonObject.neon diff --git a/utils/phpstan-baseline/nullCoalesce.variable.neon b/utils/phpstan-baseline/nullCoalesce.variable.neon deleted file mode 100644 index 3b81cc83a8f1..000000000000 --- a/utils/phpstan-baseline/nullCoalesce.variable.neon +++ /dev/null @@ -1,13 +0,0 @@ -# total 2 errors - -parameters: - ignoreErrors: - - - message: '#^Variable \$_GET on left side of \?\? always exists and is not nullable\.$#' - count: 1 - path: ../../system/HTTP/RedirectResponse.php - - - - message: '#^Variable \$_POST on left side of \?\? always exists and is not nullable\.$#' - count: 1 - path: ../../system/HTTP/RedirectResponse.php From 34d4dfe850065b6aa2e13f527b3aa286626fd2f4 Mon Sep 17 00:00:00 2001 From: warcooft Date: Mon, 14 Apr 2025 20:37:13 +0700 Subject: [PATCH 2/4] refactor: fix errors --- system/HTTP/RedirectResponse.php | 10 ++-------- utils/phpstan-baseline/loader.neon | 2 +- 2 files changed, 3 insertions(+), 9 deletions(-) diff --git a/system/HTTP/RedirectResponse.php b/system/HTTP/RedirectResponse.php index 4fb1fddb97cd..82359b82540c 100644 --- a/system/HTTP/RedirectResponse.php +++ b/system/HTTP/RedirectResponse.php @@ -92,15 +92,9 @@ public function back(?int $code = null, string $method = 'auto') public function withInput() { $session = service('session'); - - // @phpstan-ignore-next-line - $get = $_GET ?? []; - // @phpstan-ignore-next-line - $post = $_POST ?? []; - $session->setFlashdata('_ci_old_input', [ - 'get' => $get, - 'post' => $post, + 'get' => $_GET ?? [], // @phpstan-ignore-next-line + 'post' => $_POST ?? [], // @phpstan-ignore-next-line ]); $this->withErrors(); diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index f2c97f4bb57b..7ffb4839cc44 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 3541 errors +# total 3539 errors includes: - argument.type.neon - assign.propertyType.neon From cf7df3d2163052dfeaf7731cea2d4c5e880d8479 Mon Sep 17 00:00:00 2001 From: warcooft Date: Mon, 14 Apr 2025 20:44:43 +0700 Subject: [PATCH 3/4] Suppress PHPStan warning --- system/HTTP/RedirectResponse.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/system/HTTP/RedirectResponse.php b/system/HTTP/RedirectResponse.php index 82359b82540c..27299fac3275 100644 --- a/system/HTTP/RedirectResponse.php +++ b/system/HTTP/RedirectResponse.php @@ -93,8 +93,10 @@ public function withInput() { $session = service('session'); $session->setFlashdata('_ci_old_input', [ - 'get' => $_GET ?? [], // @phpstan-ignore-next-line - 'post' => $_POST ?? [], // @phpstan-ignore-next-line + // @phpstan-ignore-next-line + 'get' => $_GET ?? [], + // @phpstan-ignore-next-line + 'post' => $_POST ?? [], ]); $this->withErrors(); From 1ee19794d9f9a57a2b2d3c1acb467bad806be7c2 Mon Sep 17 00:00:00 2001 From: Aselsan Date: Mon, 14 Apr 2025 20:48:29 +0700 Subject: [PATCH 4/4] Update system/HTTP/RedirectResponse.php Co-authored-by: John Paul E. Balandan, CPA --- system/HTTP/RedirectResponse.php | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/system/HTTP/RedirectResponse.php b/system/HTTP/RedirectResponse.php index 27299fac3275..5703d1d6a78d 100644 --- a/system/HTTP/RedirectResponse.php +++ b/system/HTTP/RedirectResponse.php @@ -93,10 +93,8 @@ public function withInput() { $session = service('session'); $session->setFlashdata('_ci_old_input', [ - // @phpstan-ignore-next-line - 'get' => $_GET ?? [], - // @phpstan-ignore-next-line - 'post' => $_POST ?? [], + 'get' => $_GET ?? [], // @phpstan-ignore nullCoalesce.variable + 'post' => $_POST ?? [], // @phpstan-ignore nullCoalesce.variable ]); $this->withErrors();