Skip to content

Commit f432f41

Browse files
authored
Merge pull request #8138 from kenjis/fix-types
[4.5] refactor: fix types
2 parents c1b39dc + 966b717 commit f432f41

File tree

7 files changed

+17
-16
lines changed

7 files changed

+17
-16
lines changed

phpstan-baseline.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,6 @@
9696
'count' => 6,
9797
'path' => __DIR__ . '/system/CLI/CLI.php',
9898
];
99-
$ignoreErrors[] = [
100-
'message' => '#^Only booleans are allowed in &&, array given on the right side\\.$#',
101-
'count' => 1,
102-
'path' => __DIR__ . '/system/CLI/CLI.php',
103-
];
10499
$ignoreErrors[] = [
105100
'message' => '#^Only booleans are allowed in &&, array\\<int, string\\> given on the right side\\.$#',
106101
'count' => 1,
@@ -1158,7 +1153,7 @@
11581153
];
11591154
$ignoreErrors[] = [
11601155
'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, max\\> given\\.$#',
1161-
'count' => 4,
1156+
'count' => 3,
11621157
'path' => __DIR__ . '/system/Database/MigrationRunner.php',
11631158
];
11641159
$ignoreErrors[] = [

system/CLI/CLI.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,9 @@ public static function input(?string $prefix = null): string
213213
* // Do not provide options but requires a valid email
214214
* $email = CLI::prompt('What is your email?', null, 'required|valid_email');
215215
*
216-
* @param string $field Output "field" question
217-
* @param array|string $options String to a default value, array to a list of options (the first option will be the default value)
218-
* @param array|string|null $validation Validation rules
216+
* @param string $field Output "field" question
217+
* @param list<int|string>|string $options String to a default value, array to a list of options (the first option will be the default value)
218+
* @param array|string|null $validation Validation rules
219219
*
220220
* @return string The user input
221221
*/
@@ -237,9 +237,9 @@ public static function prompt(string $field, $options = null, $validation = null
237237
$default = $options;
238238
}
239239

240-
if (is_array($options) && $options) {
240+
if (is_array($options) && $options !== []) {
241241
$opts = $options;
242-
$extraOutputDefault = static::color($opts[0], 'green');
242+
$extraOutputDefault = static::color((string) $opts[0], 'green');
243243

244244
unset($opts[0]);
245245

system/Commands/Database/MigrateStatus.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public function run(array $params)
115115
ksort($migrations);
116116

117117
foreach ($migrations as $uid => $migration) {
118-
$migrations[$uid]->name = mb_substr($migration->name, mb_strpos($migration->name, $uid . '_'));
118+
$migrations[$uid]->name = mb_substr($migration->name, (int) mb_strpos($migration->name, $uid . '_'));
119119

120120
$date = '---';
121121
$group = '---';

system/Database/MigrationRunner.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -752,7 +752,7 @@ public function getBatchEnd(int $batch): string
752752
->get()
753753
->getResultObject();
754754

755-
return count($migration) ? $migration[0]->version : 0;
755+
return $migration === [] ? '0' : $migration[0]->version;
756756
}
757757

758758
/**

system/Session/Handlers/RedisHandler.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,13 @@ public function open($path, $name): bool
124124

125125
$redis = new Redis();
126126

127-
if (! $redis->connect($this->savePath['protocol'] . '://' . $this->savePath['host'], ($this->savePath['host'][0] === '/' ? 0 : $this->savePath['port']), $this->savePath['timeout'])) {
127+
if (
128+
! $redis->connect(
129+
$this->savePath['protocol'] . '://' . $this->savePath['host'],
130+
($this->savePath['host'][0] === '/') ? 0 : (int) $this->savePath['port'],
131+
$this->savePath['timeout']
132+
)
133+
) {
128134
$this->logger->error('Session: Unable to connect to Redis with the configured settings.');
129135
} elseif (isset($this->savePath['password']) && ! $redis->auth($this->savePath['password'])) {
130136
$this->logger->error('Session: Unable to authenticate to Redis instance.');

system/Test/CIUnitTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ public function assertHeaderNotEmitted(string $header, bool $ignoreCase = false)
439439
* where the result is close but not exactly equal to the
440440
* expected time, for reasons beyond our control.
441441
*
442-
* @param mixed $actual
442+
* @param float|int $actual
443443
*
444444
* @throws Exception
445445
*/

system/Validation/Validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -806,7 +806,7 @@ protected function fillPlaceholders(array $rules, array $data): array
806806
}
807807

808808
// Replace the placeholder in the rule
809-
$ruleSet = str_replace('{' . $field . '}', $data[$field], $ruleSet);
809+
$ruleSet = str_replace('{' . $field . '}', (string) $data[$field], $ruleSet);
810810
}
811811
}
812812
}

0 commit comments

Comments
 (0)