Skip to content

Commit c43119c

Browse files
authored
refactor: fix return.unusedType errors (#9514)
1 parent 7cd4d32 commit c43119c

File tree

8 files changed

+16
-53
lines changed

8 files changed

+16
-53
lines changed

Diff for: system/Commands/Utilities/ConfigCheck.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ final class ConfigCheck extends BaseCommand
7373
protected $options = [];
7474

7575
/**
76-
* {@inheritDoc}
76+
* @return int
7777
*/
7878
public function run(array $params)
7979
{

Diff for: system/Commands/Utilities/Environment.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,15 @@ final class Environment extends BaseCommand
8080
];
8181

8282
/**
83-
* {@inheritDoc}
83+
* @return int
8484
*/
8585
public function run(array $params)
8686
{
8787
if ($params === []) {
8888
CLI::write(sprintf('Your environment is currently set as %s.', CLI::color($_SERVER['CI_ENVIRONMENT'] ?? ENVIRONMENT, 'green')));
8989
CLI::newLine();
9090

91-
return;
91+
return EXIT_ERROR;
9292
}
9393

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

101-
return;
101+
return EXIT_ERROR;
102102
}
103103

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

108-
return;
108+
return EXIT_ERROR;
109109
}
110110

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

115-
return;
115+
return EXIT_ERROR;
116116
}
117117

118118
// force DotEnv to reload the new environment
@@ -124,6 +124,8 @@ public function run(array $params)
124124
CLI::write(sprintf('Environment is successfully changed to "%s".', $env), 'green');
125125
CLI::write('The ENVIRONMENT constant will be changed in the next script execution.');
126126
CLI::newLine();
127+
128+
return EXIT_SUCCESS;
127129
}
128130

129131
/**

Diff for: system/Commands/Utilities/Optimize.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ final class Optimize extends BaseCommand
5555
protected $usage = 'optimize';
5656

5757
/**
58-
* {@inheritDoc}
58+
* @return int
5959
*/
6060
public function run(array $params)
6161
{
6262
try {
6363
$this->enableCaching();
6464
$this->clearCache();
6565
$this->removeDevPackages();
66+
67+
return EXIT_SUCCESS;
6668
} catch (RuntimeException) {
6769
CLI::error('The "spark optimize" failed.');
6870

6971
return EXIT_ERROR;
7072
}
71-
72-
return EXIT_SUCCESS;
7373
}
7474

7575
private function clearCache(): void

Diff for: system/Commands/Utilities/PhpIniCheck.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ final class PhpIniCheck extends BaseCommand
6868
protected $options = [];
6969

7070
/**
71-
* {@inheritDoc}
71+
* @return int
7272
*/
7373
public function run(array $params)
7474
{

Diff for: system/Test/PhpStreamWrapper.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function stream_open(): bool
5252
}
5353

5454
/**
55-
* @return false|string
55+
* @return string
5656
*/
5757
public function stream_read(int $count)
5858
{
@@ -63,7 +63,7 @@ public function stream_read(int $count)
6363
}
6464

6565
/**
66-
* @return array|false
66+
* @return array{}
6767
*/
6868
public function stream_stat()
6969
{

Diff for: utils/phpstan-baseline/loader.neon

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 3615 errors
1+
# total 3608 errors
22
includes:
33
- argument.type.neon
44
- assign.propertyType.neon
@@ -35,7 +35,6 @@ includes:
3535
- property.readOnlyByPhpDocAssignOutOfClass.neon
3636
- property.readOnlyByPhpDocDefaultValue.neon
3737
- property.unusedType.neon
38-
- return.unusedType.neon
3938
- staticMethod.notFound.neon
4039
- ternary.shortNotAllowed.neon
4140
- varTag.type.neon

Diff for: utils/phpstan-baseline/missingType.iterableValue.neon

+1-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 1629 errors
1+
# total 1628 errors
22

33
parameters:
44
ignoreErrors:
@@ -5597,11 +5597,6 @@ parameters:
55975597
count: 1
55985598
path: ../../system/Test/Mock/MockResult.php
55995599

5600-
-
5601-
message: '#^Method CodeIgniter\\Test\\PhpStreamWrapper\:\:stream_stat\(\) return type has no value type specified in iterable type array\.$#'
5602-
count: 1
5603-
path: ../../system/Test/PhpStreamWrapper.php
5604-
56055600
-
56065601
message: '#^Method CodeIgniter\\Test\\TestResponse\:\:assertJSONExact\(\) has parameter \$test with no value type specified in iterable type array\.$#'
56075602
count: 1

Diff for: utils/phpstan-baseline/return.unusedType.neon

-33
This file was deleted.

0 commit comments

Comments
 (0)