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

[4.5] refactor: fix types #8138

Merged
merged 9 commits into from
Nov 7, 2023
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
7 changes: 1 addition & 6 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,6 @@
'count' => 6,
'path' => __DIR__ . '/system/CLI/CLI.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in &&, array given on the right side\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/CLI/CLI.php',
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in &&, array\\<int, string\\> given on the right side\\.$#',
'count' => 1,
Expand Down Expand Up @@ -1158,7 +1153,7 @@
];
$ignoreErrors[] = [
'message' => '#^Only booleans are allowed in a ternary operator condition, int\\<0, max\\> given\\.$#',
'count' => 4,
'count' => 3,
'path' => __DIR__ . '/system/Database/MigrationRunner.php',
];
$ignoreErrors[] = [
Expand Down
10 changes: 5 additions & 5 deletions system/CLI/CLI.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,9 +213,9 @@ public static function input(?string $prefix = null): string
* // Do not provide options but requires a valid email
* $email = CLI::prompt('What is your email?', null, 'required|valid_email');
*
* @param string $field Output "field" question
* @param array|string $options String to a default value, array to a list of options (the first option will be the default value)
* @param array|string|null $validation Validation rules
* @param string $field Output "field" question
* @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)
* @param array|string|null $validation Validation rules
*
* @return string The user input
*/
Expand All @@ -237,9 +237,9 @@ public static function prompt(string $field, $options = null, $validation = null
$default = $options;
}

if (is_array($options) && $options) {
if (is_array($options) && $options !== []) {
$opts = $options;
$extraOutputDefault = static::color($opts[0], 'green');
$extraOutputDefault = static::color((string) $opts[0], 'green');

unset($opts[0]);

Expand Down
2 changes: 1 addition & 1 deletion system/Commands/Database/MigrateStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public function run(array $params)
ksort($migrations);

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

$date = '---';
$group = '---';
Expand Down
2 changes: 1 addition & 1 deletion system/Database/MigrationRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -752,7 +752,7 @@ public function getBatchEnd(int $batch): string
->get()
->getResultObject();

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

/**
Expand Down
8 changes: 7 additions & 1 deletion system/Session/Handlers/RedisHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,13 @@ public function open($path, $name): bool

$redis = new Redis();

if (! $redis->connect($this->savePath['protocol'] . '://' . $this->savePath['host'], ($this->savePath['host'][0] === '/' ? 0 : $this->savePath['port']), $this->savePath['timeout'])) {
if (
! $redis->connect(
$this->savePath['protocol'] . '://' . $this->savePath['host'],
($this->savePath['host'][0] === '/') ? 0 : (int) $this->savePath['port'],
$this->savePath['timeout']
)
) {
$this->logger->error('Session: Unable to connect to Redis with the configured settings.');
} elseif (isset($this->savePath['password']) && ! $redis->auth($this->savePath['password'])) {
$this->logger->error('Session: Unable to authenticate to Redis instance.');
Expand Down
2 changes: 1 addition & 1 deletion system/Test/CIUnitTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ public function assertHeaderNotEmitted(string $header, bool $ignoreCase = false)
* where the result is close but not exactly equal to the
* expected time, for reasons beyond our control.
*
* @param mixed $actual
* @param float|int $actual
*
* @throws Exception
*/
Expand Down
2 changes: 1 addition & 1 deletion system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -806,7 +806,7 @@ protected function fillPlaceholders(array $rules, array $data): array
}

// Replace the placeholder in the rule
$ruleSet = str_replace('{' . $field . '}', $data[$field], $ruleSet);
$ruleSet = str_replace('{' . $field . '}', (string) $data[$field], $ruleSet);
}
}
}
Expand Down
Loading