diff --git a/system/Commands/ListCommands.php b/system/Commands/ListCommands.php index 3411b103430d..8761e2bb7bbc 100644 --- a/system/Commands/ListCommands.php +++ b/system/Commands/ListCommands.php @@ -71,6 +71,8 @@ class ListCommands extends BaseCommand /** * Displays the help for the spark cli script itself. + * + * @return int */ public function run(array $params) { @@ -78,7 +80,7 @@ public function run(array $params) ksort($commands); // Check for 'simple' format - return array_key_exists('simple', $params) || CLI::getOption('simple') + return array_key_exists('simple', $params) || CLI::getOption('simple') === true ? $this->listSimple($commands) : $this->listFull($commands); } @@ -86,7 +88,7 @@ public function run(array $params) /** * Lists the commands with accompanying info. * - * @return void + * @return int */ protected function listFull(array $commands) { @@ -124,17 +126,21 @@ protected function listFull(array $commands) CLI::newLine(); } } + + return EXIT_SUCCESS; } /** * Lists the commands only. * - * @return void + * @return int */ protected function listSimple(array $commands) { foreach (array_keys($commands) as $title) { CLI::write($title); } + + return EXIT_SUCCESS; } } diff --git a/tests/system/Log/LoggerTest.php b/tests/system/Log/LoggerTest.php index 9464d4d286fd..0db30a93070d 100644 --- a/tests/system/Log/LoggerTest.php +++ b/tests/system/Log/LoggerTest.php @@ -20,6 +20,8 @@ use CodeIgniter\Test\Mock\MockLogger as LoggerConfig; use Exception; use PHPUnit\Framework\Attributes\Group; +use ReflectionMethod; +use ReflectionNamedType; use Tests\Support\Log\Handlers\TestHandler; use TypeError; @@ -67,7 +69,10 @@ public function testLogAlwaysReturnsVoid(): void $logger = new Logger($config); - $this->assertNull($logger->log('debug', '')); + $refMethod = new ReflectionMethod($logger, 'log'); + $this->assertTrue($refMethod->hasReturnType()); + $this->assertInstanceOf(ReflectionNamedType::class, $refMethod->getReturnType()); + $this->assertSame('void', $refMethod->getReturnType()->getName()); } public function testLogActuallyLogs(): void diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 8118710b2257..1746fc32470a 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -37,7 +37,6 @@ includes: - method.impossibleType.neon - method.notFound.neon - method.unused.neon - - method.void.neon - missingType.callable.neon - missingType.iterableValue.neon - missingType.parameter.neon diff --git a/utils/phpstan-baseline/method.void.neon b/utils/phpstan-baseline/method.void.neon deleted file mode 100644 index 09d958a496e7..000000000000 --- a/utils/phpstan-baseline/method.void.neon +++ /dev/null @@ -1,18 +0,0 @@ -# total 3 errors - -parameters: - ignoreErrors: - - - message: '#^Result of method CodeIgniter\\Commands\\ListCommands\:\:listFull\(\) \(void\) is used\.$#' - count: 1 - path: ../../system/Commands/ListCommands.php - - - - message: '#^Result of method CodeIgniter\\Commands\\ListCommands\:\:listSimple\(\) \(void\) is used\.$#' - count: 1 - path: ../../system/Commands/ListCommands.php - - - - message: '#^Result of method CodeIgniter\\Log\\Logger\:\:log\(\) \(void\) is used\.$#' - count: 1 - path: ../../tests/system/Log/LoggerTest.php