Skip to content

Commit 19ad2b9

Browse files
authored
refactor: fix used void return type (#9341)
1 parent e363f47 commit 19ad2b9

File tree

4 files changed

+15
-23
lines changed

4 files changed

+15
-23
lines changed

system/Commands/ListCommands.php

+9-3
Original file line numberDiff line numberDiff line change
@@ -71,22 +71,24 @@ class ListCommands extends BaseCommand
7171

7272
/**
7373
* Displays the help for the spark cli script itself.
74+
*
75+
* @return int
7476
*/
7577
public function run(array $params)
7678
{
7779
$commands = $this->commands->getCommands();
7880
ksort($commands);
7981

8082
// Check for 'simple' format
81-
return array_key_exists('simple', $params) || CLI::getOption('simple')
83+
return array_key_exists('simple', $params) || CLI::getOption('simple') === true
8284
? $this->listSimple($commands)
8385
: $this->listFull($commands);
8486
}
8587

8688
/**
8789
* Lists the commands with accompanying info.
8890
*
89-
* @return void
91+
* @return int
9092
*/
9193
protected function listFull(array $commands)
9294
{
@@ -124,17 +126,21 @@ protected function listFull(array $commands)
124126
CLI::newLine();
125127
}
126128
}
129+
130+
return EXIT_SUCCESS;
127131
}
128132

129133
/**
130134
* Lists the commands only.
131135
*
132-
* @return void
136+
* @return int
133137
*/
134138
protected function listSimple(array $commands)
135139
{
136140
foreach (array_keys($commands) as $title) {
137141
CLI::write($title);
138142
}
143+
144+
return EXIT_SUCCESS;
139145
}
140146
}

tests/system/Log/LoggerTest.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
use CodeIgniter\Test\Mock\MockLogger as LoggerConfig;
2121
use Exception;
2222
use PHPUnit\Framework\Attributes\Group;
23+
use ReflectionMethod;
24+
use ReflectionNamedType;
2325
use Tests\Support\Log\Handlers\TestHandler;
2426
use TypeError;
2527

@@ -67,7 +69,10 @@ public function testLogAlwaysReturnsVoid(): void
6769

6870
$logger = new Logger($config);
6971

70-
$this->assertNull($logger->log('debug', ''));
72+
$refMethod = new ReflectionMethod($logger, 'log');
73+
$this->assertTrue($refMethod->hasReturnType());
74+
$this->assertInstanceOf(ReflectionNamedType::class, $refMethod->getReturnType());
75+
$this->assertSame('void', $refMethod->getReturnType()->getName());
7176
}
7277

7378
public function testLogActuallyLogs(): void

utils/phpstan-baseline/loader.neon

-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ includes:
3737
- method.impossibleType.neon
3838
- method.notFound.neon
3939
- method.unused.neon
40-
- method.void.neon
4140
- missingType.callable.neon
4241
- missingType.iterableValue.neon
4342
- missingType.parameter.neon

utils/phpstan-baseline/method.void.neon

-18
This file was deleted.

0 commit comments

Comments
 (0)