diff --git a/phpstan-baseline.php b/phpstan-baseline.php index 11487806e48d..8c5d7a06625e 100644 --- a/phpstan-baseline.php +++ b/phpstan-baseline.php @@ -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\\ given on the right side\\.$#', 'count' => 1, @@ -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[] = [ diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 27ea440703cc..c6bcb3557590 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -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|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 */ @@ -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]); diff --git a/system/Commands/Database/MigrateStatus.php b/system/Commands/Database/MigrateStatus.php index af3cbacf772c..cc7fe7d1ef02 100644 --- a/system/Commands/Database/MigrateStatus.php +++ b/system/Commands/Database/MigrateStatus.php @@ -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 = '---'; diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index 241a9e6da5fa..1df8aaf2e80f 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -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; } /** diff --git a/system/Session/Handlers/RedisHandler.php b/system/Session/Handlers/RedisHandler.php index 1fb87597ab8a..690860c6175e 100644 --- a/system/Session/Handlers/RedisHandler.php +++ b/system/Session/Handlers/RedisHandler.php @@ -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.'); diff --git a/system/Test/CIUnitTestCase.php b/system/Test/CIUnitTestCase.php index 4e889b5ea1d0..266a22b0161d 100644 --- a/system/Test/CIUnitTestCase.php +++ b/system/Test/CIUnitTestCase.php @@ -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 */ diff --git a/system/Validation/Validation.php b/system/Validation/Validation.php index d14986164e63..747ac66d9bc4 100644 --- a/system/Validation/Validation.php +++ b/system/Validation/Validation.php @@ -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); } } }