Skip to content

refactor: fix return.unusedType errors #9514

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

Merged
merged 1 commit into from
Apr 13, 2025
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
2 changes: 1 addition & 1 deletion system/Commands/Utilities/ConfigCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ final class ConfigCheck extends BaseCommand
protected $options = [];

/**
* {@inheritDoc}
* @return int
*/
public function run(array $params)
{
Expand Down
12 changes: 7 additions & 5 deletions system/Commands/Utilities/Environment.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ final class Environment extends BaseCommand
];

/**
* {@inheritDoc}
* @return int
*/
public function run(array $params)
{
if ($params === []) {
CLI::write(sprintf('Your environment is currently set as %s.', CLI::color($_SERVER['CI_ENVIRONMENT'] ?? ENVIRONMENT, 'green')));
CLI::newLine();

return;
return EXIT_ERROR;
}

$env = strtolower(array_shift($params));
Expand All @@ -98,21 +98,21 @@ public function run(array $params)
CLI::error('You will not be able to run spark under a "testing" environment.', 'light_gray', 'red');
CLI::newLine();

return;
return EXIT_ERROR;
}

if (! in_array($env, self::$knownTypes, true)) {
CLI::error(sprintf('Invalid environment type "%s". Expected one of "%s".', $env, implode('" and "', self::$knownTypes)), 'light_gray', 'red');
CLI::newLine();

return;
return EXIT_ERROR;
}

if (! $this->writeNewEnvironmentToEnvFile($env)) {
CLI::error('Error in writing new environment to .env file.', 'light_gray', 'red');
CLI::newLine();

return;
return EXIT_ERROR;
}

// force DotEnv to reload the new environment
Expand All @@ -124,6 +124,8 @@ public function run(array $params)
CLI::write(sprintf('Environment is successfully changed to "%s".', $env), 'green');
CLI::write('The ENVIRONMENT constant will be changed in the next script execution.');
CLI::newLine();

return EXIT_SUCCESS;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions system/Commands/Utilities/Optimize.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,21 @@ final class Optimize extends BaseCommand
protected $usage = 'optimize';

/**
* {@inheritDoc}
* @return int
*/
public function run(array $params)
{
try {
$this->enableCaching();
$this->clearCache();
$this->removeDevPackages();

return EXIT_SUCCESS;
} catch (RuntimeException) {
CLI::error('The "spark optimize" failed.');

return EXIT_ERROR;
}

return EXIT_SUCCESS;
}

private function clearCache(): void
Expand Down
2 changes: 1 addition & 1 deletion system/Commands/Utilities/PhpIniCheck.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ final class PhpIniCheck extends BaseCommand
protected $options = [];

/**
* {@inheritDoc}
* @return int
*/
public function run(array $params)
{
Expand Down
4 changes: 2 additions & 2 deletions system/Test/PhpStreamWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public function stream_open(): bool
}

/**
* @return false|string
* @return string
*/
public function stream_read(int $count)
{
Expand All @@ -63,7 +63,7 @@ public function stream_read(int $count)
}

/**
* @return array|false
* @return array{}
*/
public function stream_stat()
{
Expand Down
3 changes: 1 addition & 2 deletions utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 3615 errors
# total 3608 errors
includes:
- argument.type.neon
- assign.propertyType.neon
Expand Down Expand Up @@ -35,7 +35,6 @@ includes:
- property.readOnlyByPhpDocAssignOutOfClass.neon
- property.readOnlyByPhpDocDefaultValue.neon
- property.unusedType.neon
- return.unusedType.neon
- staticMethod.notFound.neon
- ternary.shortNotAllowed.neon
- varTag.type.neon
7 changes: 1 addition & 6 deletions utils/phpstan-baseline/missingType.iterableValue.neon
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# total 1629 errors
# total 1628 errors

parameters:
ignoreErrors:
Expand Down Expand Up @@ -5597,11 +5597,6 @@ parameters:
count: 1
path: ../../system/Test/Mock/MockResult.php

-
message: '#^Method CodeIgniter\\Test\\PhpStreamWrapper\:\:stream_stat\(\) return type has no value type specified in iterable type array\.$#'
count: 1
path: ../../system/Test/PhpStreamWrapper.php

-
message: '#^Method CodeIgniter\\Test\\TestResponse\:\:assertJSONExact\(\) has parameter \$test with no value type specified in iterable type array\.$#'
count: 1
Expand Down
33 changes: 0 additions & 33 deletions utils/phpstan-baseline/return.unusedType.neon

This file was deleted.

Loading