From 3bafbe64642b41de9248179f17b2bee0f56c6499 Mon Sep 17 00:00:00 2001 From: kenjis Date: Wed, 12 Oct 2022 11:26:54 +0900 Subject: [PATCH 1/5] fix: valid_date does not work in PHP 8.2 See https://github.com/php/php-src/issues/9431#issuecomment-1230316507 --- system/Validation/FormatRules.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/system/Validation/FormatRules.php b/system/Validation/FormatRules.php index 1683fd8367a7..bc4301c2a086 100644 --- a/system/Validation/FormatRules.php +++ b/system/Validation/FormatRules.php @@ -344,6 +344,15 @@ public function valid_date(?string $str = null, ?string $format = null): bool $date = DateTime::createFromFormat($format, $str); $errors = DateTime::getLastErrors(); - return $date !== false && $errors !== false && $errors['warning_count'] === 0 && $errors['error_count'] === 0; + if ($date === false) { + return false; + } + + // PHP 8.2 or later. + if ($errors === false) { + return true; + } + + return $errors['warning_count'] === 0 && $errors['error_count'] === 0; } } From efd24e055dce550da9b2ee502d5c31a0c6338919 Mon Sep 17 00:00:00 2001 From: kenjis Date: Thu, 13 Oct 2022 11:16:50 +0900 Subject: [PATCH 2/5] chore: add extensions in suggest --- admin/framework/composer.json | 2 ++ composer.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/admin/framework/composer.json b/admin/framework/composer.json index ea5e3ac9faa2..66f1adb58bcf 100644 --- a/admin/framework/composer.json +++ b/admin/framework/composer.json @@ -34,6 +34,8 @@ "ext-memcache": "If you use Cache class MemcachedHandler with Memcache", "ext-memcached": "If you use Cache class MemcachedHandler with Memcached", "ext-redis": "If you use Cache class RedisHandler", + "ext-dom": "If you use TestResponse", + "ext-libxml": "If you use TestResponse", "ext-fileinfo": "Improves mime type detection for files", "ext-readline": "Improves CLI::input() usability" }, diff --git a/composer.json b/composer.json index 8fca22ded575..c5ce9f91d0e8 100644 --- a/composer.json +++ b/composer.json @@ -37,6 +37,8 @@ "ext-memcache": "If you use Cache class MemcachedHandler with Memcache", "ext-memcached": "If you use Cache class MemcachedHandler with Memcached", "ext-redis": "If you use Cache class RedisHandler", + "ext-dom": "If you use TestResponse", + "ext-libxml": "If you use TestResponse", "ext-fileinfo": "Improves mime type detection for files", "ext-readline": "Improves CLI::input() usability" }, From 1f421777d1da7c90b5cd8018f317ba1495b70a44 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 13 Oct 2022 20:47:25 +0800 Subject: [PATCH 3/5] Updates the requirements on friendsofphp/php-cs-fixer to permit the latest version. --- admin/framework/composer.json | 2 +- composer.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/admin/framework/composer.json b/admin/framework/composer.json index ea5e3ac9faa2..d2e787e5e035 100644 --- a/admin/framework/composer.json +++ b/admin/framework/composer.json @@ -17,7 +17,7 @@ "require-dev": { "codeigniter/coding-standard": "^1.5", "fakerphp/faker": "^1.9", - "friendsofphp/php-cs-fixer": "~3.11.0", + "friendsofphp/php-cs-fixer": "~3.12.0", "mikey179/vfsstream": "^1.6", "nexusphp/cs-config": "^3.6", "phpunit/phpunit": "^9.1", diff --git a/composer.json b/composer.json index 8fca22ded575..99e3b68d96b6 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ "require-dev": { "codeigniter/coding-standard": "^1.5", "fakerphp/faker": "^1.9", - "friendsofphp/php-cs-fixer": "~3.11.0", + "friendsofphp/php-cs-fixer": "~3.12.0", "mikey179/vfsstream": "^1.6", "nexusphp/cs-config": "^3.6", "nexusphp/tachycardia": "^1.0", From 616a4cc45702ae0e58693208603ecfaea3f66373 Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 13 Oct 2022 20:51:17 +0800 Subject: [PATCH 4/5] Apply linting fixes --- tests/_support/Log/Handlers/TestHandler.php | 3 --- tests/system/Config/MimesTest.php | 1 - tests/system/Validation/FormatRulesTest.php | 3 --- 3 files changed, 7 deletions(-) diff --git a/tests/_support/Log/Handlers/TestHandler.php b/tests/_support/Log/Handlers/TestHandler.php index e20a32c2b0b6..6297aff42bd0 100644 --- a/tests/_support/Log/Handlers/TestHandler.php +++ b/tests/_support/Log/Handlers/TestHandler.php @@ -46,9 +46,6 @@ public function __construct(array $config) * If the handler returns false, then execution of handlers * will stop. Any handlers that have not run, yet, will not * be run. - * - * @param $level - * @param $message */ public function handle($level, $message): bool { diff --git a/tests/system/Config/MimesTest.php b/tests/system/Config/MimesTest.php index cbd389882fcf..d9d27128142c 100644 --- a/tests/system/Config/MimesTest.php +++ b/tests/system/Config/MimesTest.php @@ -48,7 +48,6 @@ public function extensionsList() /** * @dataProvider extensionsList * - * @param $expected * @param $ext * @param mixed $mime */ diff --git a/tests/system/Validation/FormatRulesTest.php b/tests/system/Validation/FormatRulesTest.php index 4cf445ee950d..fda3670344f7 100644 --- a/tests/system/Validation/FormatRulesTest.php +++ b/tests/system/Validation/FormatRulesTest.php @@ -411,9 +411,6 @@ public function stringProvider(): Generator /** * @dataProvider alphaProvider - * - * @param $str - * @param $expected */ public function testAlpha(?string $str, bool $expected): void { From f0a67617bf38364f4f065371a6ad91340f4d759e Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Thu, 13 Oct 2022 20:53:19 +0800 Subject: [PATCH 5/5] Fix parameter types --- tests/_support/Log/Handlers/TestHandler.php | 3 +++ tests/system/Config/MimesTest.php | 10 ++-------- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/_support/Log/Handlers/TestHandler.php b/tests/_support/Log/Handlers/TestHandler.php index 6297aff42bd0..82c893e271e9 100644 --- a/tests/_support/Log/Handlers/TestHandler.php +++ b/tests/_support/Log/Handlers/TestHandler.php @@ -46,6 +46,9 @@ public function __construct(array $config) * If the handler returns false, then execution of handlers * will stop. Any handlers that have not run, yet, will not * be run. + * + * @param string $level + * @param string $message */ public function handle($level, $message): bool { diff --git a/tests/system/Config/MimesTest.php b/tests/system/Config/MimesTest.php index d9d27128142c..35d9c9819100 100644 --- a/tests/system/Config/MimesTest.php +++ b/tests/system/Config/MimesTest.php @@ -47,11 +47,8 @@ public function extensionsList() /** * @dataProvider extensionsList - * - * @param $ext - * @param mixed $mime */ - public function testGuessExtensionFromType($expected, $mime) + public function testGuessExtensionFromType(?string $expected, string $mime) { $this->assertSame($expected, Mimes::guessExtensionFromType($mime)); } @@ -84,11 +81,8 @@ public function mimesList() /** * @dataProvider mimesList - * - * @param mixed $expected - * @param mixed $ext */ - public function testGuessTypeFromExtension($expected, $ext) + public function testGuessTypeFromExtension(?string $expected, string $ext) { $this->assertSame($expected, Mimes::guessTypeFromExtension($ext)); }