From 1947c6716055c0367aeb74940752ea529be10c7c Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Tue, 30 Jun 2026 12:31:18 +0800 Subject: [PATCH] refactor: do not use direct access and unset on `$_COOKIE` and `$_POST` --- tests/system/Debug/ExceptionHandlerTest.php | 7 ++++--- .../codeigniter.superglobalsOffsetAssign.neon | 13 ------------- .../codeigniter.superglobalsOffsetUnset.neon | 13 ------------- utils/phpstan-baseline/loader.neon | 4 +--- 4 files changed, 5 insertions(+), 32 deletions(-) delete mode 100644 utils/phpstan-baseline/codeigniter.superglobalsOffsetAssign.neon delete mode 100644 utils/phpstan-baseline/codeigniter.superglobalsOffsetUnset.neon diff --git a/tests/system/Debug/ExceptionHandlerTest.php b/tests/system/Debug/ExceptionHandlerTest.php index 0b44a9d83b23..2a5ecbb78cdf 100644 --- a/tests/system/Debug/ExceptionHandlerTest.php +++ b/tests/system/Debug/ExceptionHandlerTest.php @@ -127,8 +127,9 @@ public function testCopyErrorReportOmitsSensitiveRequestDataAndTraceArgs(): void { $exception = $this->createExceptionWithSensitiveTraceArgument(); - $_COOKIE['debug_cookie'] = 'cookie-secret'; - $_POST['debug_post'] = 'post-secret'; + service('superglobals') + ->setCookie('debug_cookie', 'cookie-secret') + ->setPost('debug_post', 'post-secret'); try { $report = $this->extractCopyableErrorReport($this->renderHtmlException($exception)); @@ -139,7 +140,7 @@ public function testCopyErrorReportOmitsSensitiveRequestDataAndTraceArgs(): void $this->assertStringNotContainsString('$_COOKIE', $report); $this->assertStringNotContainsString('$_POST', $report); } finally { - unset($_COOKIE['debug_cookie'], $_POST['debug_post']); + service('superglobals')->unsetCookie('debug_cookie')->unsetPost('debug_post'); } } diff --git a/utils/phpstan-baseline/codeigniter.superglobalsOffsetAssign.neon b/utils/phpstan-baseline/codeigniter.superglobalsOffsetAssign.neon deleted file mode 100644 index 3f7d0a28910c..000000000000 --- a/utils/phpstan-baseline/codeigniter.superglobalsOffsetAssign.neon +++ /dev/null @@ -1,13 +0,0 @@ -# total 2 errors - -parameters: - ignoreErrors: - - - message: '#^Direct assignment of ''cookie\-secret'' to \$_COOKIE\[''debug_cookie''\] is not allowed\.$#' - count: 1 - path: ../../tests/system/Debug/ExceptionHandlerTest.php - - - - message: '#^Direct assignment of ''post\-secret'' to \$_POST\[''debug_post''\] is not allowed\.$#' - count: 1 - path: ../../tests/system/Debug/ExceptionHandlerTest.php diff --git a/utils/phpstan-baseline/codeigniter.superglobalsOffsetUnset.neon b/utils/phpstan-baseline/codeigniter.superglobalsOffsetUnset.neon deleted file mode 100644 index 76b66fa9cc74..000000000000 --- a/utils/phpstan-baseline/codeigniter.superglobalsOffsetUnset.neon +++ /dev/null @@ -1,13 +0,0 @@ -# total 2 errors - -parameters: - ignoreErrors: - - - message: '#^Direct unset of \$_COOKIE\[''debug_cookie''\] is not allowed\.$#' - count: 1 - path: ../../tests/system/Debug/ExceptionHandlerTest.php - - - - message: '#^Direct unset of \$_POST\[''debug_post''\] is not allowed\.$#' - count: 1 - path: ../../tests/system/Debug/ExceptionHandlerTest.php diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 60950e3e2919..92c779e138df 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,12 +1,10 @@ -# total 1799 errors +# total 1795 errors includes: - argument.type.neon - arguments.count.neon - assign.propertyType.neon - codeigniter.modelArgumentType.neon - - codeigniter.superglobalsOffsetAssign.neon - - codeigniter.superglobalsOffsetUnset.neon - deadCode.unreachable.neon - empty.notAllowed.neon - function.resultUnused.neon