From aefdb499521894245884224f6339c43bb4ef944f Mon Sep 17 00:00:00 2001 From: "John Paul E. Balandan, CPA" Date: Fri, 28 Aug 2026 12:49:47 +0800 Subject: [PATCH] refactor: fix phpstan errors in `AutoReview` --- tests/system/AutoReview/ComposerJsonTest.php | 18 +++++++ tests/system/AutoReview/FrameworkCodeTest.php | 11 ++++ utils/phpstan-baseline/loader.neon | 2 +- .../missingType.iterableValue.neon | 52 +------------------ 4 files changed, 31 insertions(+), 52 deletions(-) diff --git a/tests/system/AutoReview/ComposerJsonTest.php b/tests/system/AutoReview/ComposerJsonTest.php index ab6b98b3bd64..55f22adb892b 100644 --- a/tests/system/AutoReview/ComposerJsonTest.php +++ b/tests/system/AutoReview/ComposerJsonTest.php @@ -26,8 +26,19 @@ #[Group('AutoReview')] final class ComposerJsonTest extends TestCase { + /** + * @var array + */ private array $devComposer; + + /** + * @var array + */ private array $frameworkComposer; + + /** + * @var array + */ private array $starterComposer; protected function setUp(): void @@ -105,6 +116,10 @@ private function checkSection(string $section, string $component): void ); } + /** + * @param array $fromMain + * @param array $fromComponent + */ private function checkConfig(array $fromMain, array $fromComponent, string $component): void { foreach ($fromMain as $key => $expectedValue) { @@ -124,6 +139,9 @@ private function checkConfig(array $fromMain, array $fromComponent, string $comp } } + /** + * @return array + */ private function getComposerJson(string $path): array { try { diff --git a/tests/system/AutoReview/FrameworkCodeTest.php b/tests/system/AutoReview/FrameworkCodeTest.php index 7345b5dfa537..812131f80509 100644 --- a/tests/system/AutoReview/FrameworkCodeTest.php +++ b/tests/system/AutoReview/FrameworkCodeTest.php @@ -31,9 +31,14 @@ final class FrameworkCodeTest extends TestCase { /** * Cache of discovered test class names. + * + * @var list */ private static array $testClasses = []; + /** + * @var list + */ private static array $recognizedGroupAttributeNames = [ 'AutoReview', 'CacheLive', @@ -79,6 +84,9 @@ public function testEachTestClassHasCorrectGroupAttributeName(string $class): vo )); } + /** + * @return iterable + */ public static function provideEachTestClassHasCorrectGroupAttributeName(): iterable { foreach (self::getTestClasses() as $class) { @@ -86,6 +94,9 @@ public static function provideEachTestClassHasCorrectGroupAttributeName(): itera } } + /** + * @return list + */ private static function getTestClasses(): array { if (self::$testClasses !== []) { diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 8cfa166d48df..296f8148b260 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,4 +1,4 @@ -# total 112 errors +# total 102 errors includes: - argument.type.neon diff --git a/utils/phpstan-baseline/missingType.iterableValue.neon b/utils/phpstan-baseline/missingType.iterableValue.neon index b426389b6a68..de7951be1665 100644 --- a/utils/phpstan-baseline/missingType.iterableValue.neon +++ b/utils/phpstan-baseline/missingType.iterableValue.neon @@ -1,4 +1,4 @@ -# total 68 errors +# total 58 errors parameters: ignoreErrors: @@ -172,56 +172,6 @@ parameters: count: 1 path: ../../system/View/Cells/Cell.php - - - message: '#^Method CodeIgniter\\AutoReview\\ComposerJsonTest\:\:checkConfig\(\) has parameter \$fromComponent with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/AutoReview/ComposerJsonTest.php - - - - message: '#^Method CodeIgniter\\AutoReview\\ComposerJsonTest\:\:checkConfig\(\) has parameter \$fromMain with no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/AutoReview/ComposerJsonTest.php - - - - message: '#^Method CodeIgniter\\AutoReview\\ComposerJsonTest\:\:getComposerJson\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/AutoReview/ComposerJsonTest.php - - - - message: '#^Property CodeIgniter\\AutoReview\\ComposerJsonTest\:\:\$devComposer type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/AutoReview/ComposerJsonTest.php - - - - message: '#^Property CodeIgniter\\AutoReview\\ComposerJsonTest\:\:\$frameworkComposer type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/AutoReview/ComposerJsonTest.php - - - - message: '#^Property CodeIgniter\\AutoReview\\ComposerJsonTest\:\:\$starterComposer type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/AutoReview/ComposerJsonTest.php - - - - message: '#^Method CodeIgniter\\AutoReview\\FrameworkCodeTest\:\:getTestClasses\(\) return type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/AutoReview/FrameworkCodeTest.php - - - - message: '#^Method CodeIgniter\\AutoReview\\FrameworkCodeTest\:\:provideEachTestClassHasCorrectGroupAttributeName\(\) return type has no value type specified in iterable type iterable\.$#' - count: 1 - path: ../../tests/system/AutoReview/FrameworkCodeTest.php - - - - message: '#^Property CodeIgniter\\AutoReview\\FrameworkCodeTest\:\:\$recognizedGroupAttributeNames type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/AutoReview/FrameworkCodeTest.php - - - - message: '#^Property CodeIgniter\\AutoReview\\FrameworkCodeTest\:\:\$testClasses type has no value type specified in iterable type array\.$#' - count: 1 - path: ../../tests/system/AutoReview/FrameworkCodeTest.php - - message: '#^Method CodeIgniter\\CLI\\CLITest\:\:provideTable\(\) return type has no value type specified in iterable type iterable\.$#' count: 1