From 15c890967484368a838be85d49e87e34c7833ab4 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Fri, 28 Aug 2026 13:14:19 +0800 Subject: [PATCH] refactor: fix missing parameter types --- tests/system/Entity/EntityTest.php | 17 ++++++++--------- .../SecurityCSRFSessionRandomizeTokenTest.php | 5 ++++- .../Security/SecurityCSRFSessionTest.php | 5 ++++- utils/phpstan-baseline/loader.neon | 3 +-- .../missingType.parameter.neon | 18 ------------------ 5 files changed, 17 insertions(+), 31 deletions(-) delete mode 100644 utils/phpstan-baseline/missingType.parameter.neon diff --git a/tests/system/Entity/EntityTest.php b/tests/system/Entity/EntityTest.php index 5233a28deeaf..82ff14253d17 100644 --- a/tests/system/Entity/EntityTest.php +++ b/tests/system/Entity/EntityTest.php @@ -502,22 +502,18 @@ public function testCastDateTime(): void public function testCastDateTimeWithTimestampTimezone(): void { - // Save the current timezone. $tz = date_default_timezone_get(); - - // Change the timezone other than UTC. - date_default_timezone_set('Asia/Tokyo'); // +09:00 + date_default_timezone_set('Asia/Tokyo'); $entity = $this->getCastEntity(); $entity->eighth = 1722988800; // 2024-08-07 00:00:00 UTC - $this->assertInstanceOf(DateTimeInterface::class, $entity->eighth); + $this->assertInstanceOf(Time::class, $entity->eighth); // The timezone is the default timezone, not UTC. $this->assertSame('2024-08-07 09:00:00', $entity->eighth->format('Y-m-d H:i:s')); $this->assertSame('Asia/Tokyo', $entity->eighth->getTimezoneName()); - // Restore timezone. date_default_timezone_set($tz); } @@ -651,8 +647,8 @@ public function testCastAsJSON(): void $check = $this->getPrivateProperty($entity, 'attributes')['tenth']; $this->assertSame('{"foo":"bar"}', $check); - $this->assertInstanceOf('stdClass', $entity->tenth); - $this->assertSame(['foo' => 'bar'], (array) $entity->tenth); + $this->assertInstanceOf(stdClass::class, $entity->tenth); + $this->assertSame('bar', $entity->tenth->foo); } public function testCastAsJSONArray(): void @@ -1744,7 +1740,10 @@ private function getSimpleSwappedEntity(): object }; } - private function getCastEntity($data = null): object + /** + * @param array|null $data + */ + private function getCastEntity(?array $data = null): Entity { return new class ($data) extends Entity { protected $attributes = [ diff --git a/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php b/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php index f5f1f437c83d..1c242e249519 100644 --- a/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php +++ b/tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php @@ -76,7 +76,10 @@ protected function setUp(): void $this->injectSession($this->hash); } - private function createSession($options = []): Session + /** + * @param array $options + */ + private function createSession(array $options = []): Session { $defaults = [ 'driver' => FileHandler::class, diff --git a/tests/system/Security/SecurityCSRFSessionTest.php b/tests/system/Security/SecurityCSRFSessionTest.php index fb410ac71ac3..fbb28e5baaf1 100644 --- a/tests/system/Security/SecurityCSRFSessionTest.php +++ b/tests/system/Security/SecurityCSRFSessionTest.php @@ -69,7 +69,10 @@ protected function setUp(): void $this->injectSession($this->hash); } - private function createSession($options = []): Session + /** + * @param array $options + */ + private function createSession(array $options = []): Session { $defaults = [ 'driver' => FileHandler::class, diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 296f8148b260..e796bfe1763f 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 102 errors +# total 99 errors includes: - argument.type.neon @@ -10,6 +10,5 @@ includes: - method.childReturnType.neon - method.notFound.neon - missingType.iterableValue.neon - - missingType.parameter.neon - property.defaultValue.neon - property.phpDocType.neon diff --git a/utils/phpstan-baseline/missingType.parameter.neon b/utils/phpstan-baseline/missingType.parameter.neon deleted file mode 100644 index 49f9dffb6507..000000000000 --- a/utils/phpstan-baseline/missingType.parameter.neon +++ /dev/null @@ -1,18 +0,0 @@ -# total 3 errors - -parameters: - ignoreErrors: - - - message: '#^Method CodeIgniter\\Entity\\EntityTest\:\:getCastEntity\(\) has parameter \$data with no type specified\.$#' - count: 1 - path: ../../tests/system/Entity/EntityTest.php - - - - message: '#^Method CodeIgniter\\Security\\SecurityCSRFSessionRandomizeTokenTest\:\:createSession\(\) has parameter \$options with no type specified\.$#' - count: 1 - path: ../../tests/system/Security/SecurityCSRFSessionRandomizeTokenTest.php - - - - message: '#^Method CodeIgniter\\Security\\SecurityCSRFSessionTest\:\:createSession\(\) has parameter \$options with no type specified\.$#' - count: 1 - path: ../../tests/system/Security/SecurityCSRFSessionTest.php