Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix used void return type #9341

Merged
merged 1 commit into from
Dec 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions system/Commands/ListCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,22 +71,24 @@ class ListCommands extends BaseCommand

/**
* Displays the help for the spark cli script itself.
*
* @return int
*/
public function run(array $params)
{
$commands = $this->commands->getCommands();
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);
}

/**
* Lists the commands with accompanying info.
*
* @return void
* @return int
*/
protected function listFull(array $commands)
{
Expand Down Expand Up @@ -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;
}
}
7 changes: 6 additions & 1 deletion tests/system/Log/LoggerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 0 additions & 18 deletions utils/phpstan-baseline/method.void.neon

This file was deleted.

Loading