diff --git a/system/BaseModel.php b/system/BaseModel.php index 0d4a7b3979b3..05c5459d8c4b 100644 --- a/system/BaseModel.php +++ b/system/BaseModel.php @@ -639,7 +639,7 @@ public function findColumn(string $columnName) $resultSet = $this->doFindColumn($columnName); - return $resultSet ? array_column($resultSet, $columnName) : null; + return $resultSet !== null ? array_column($resultSet, $columnName) : null; } /** @@ -1137,7 +1137,7 @@ public function delete($id = null, bool $purge = false) throw new InvalidArgumentException('delete(): argument #1 ($id) should not be boolean.'); } - if ($id && (is_numeric($id) || is_string($id))) { + if (! in_array($id, [null, 0, '0'], true) && (is_numeric($id) || is_string($id))) { $id = [$id]; } @@ -1250,7 +1250,7 @@ public function errors(bool $forceDB = false) } // Do we have validation errors? - if (! $forceDB && ! $this->skipValidation && ($errors = $this->validation->getErrors())) { + if (! $forceDB && ! $this->skipValidation && ($errors = $this->validation->getErrors()) !== []) { return $errors; } diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 236e5b685fff..185f51e3635c 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -225,12 +225,12 @@ public static function prompt(string $field, $options = null, $validation = null $extraOutput = ''; $default = ''; - if ($validation && ! is_array($validation) && ! is_string($validation)) { + if (isset($validation) && ! is_array($validation) && ! is_string($validation)) { throw new InvalidArgumentException('$rules can only be of type string|array'); } if (! is_array($validation)) { - $validation = $validation ? explode('|', $validation) : []; + $validation = ($validation !== null) ? explode('|', $validation) : []; } if (is_string($options)) { @@ -441,7 +441,7 @@ protected static function validate(string $field, string $value, $rules): bool */ public static function print(string $text = '', ?string $foreground = null, ?string $background = null) { - if ($foreground || $background) { + if ((string) $foreground !== '' || (string) $background !== '') { $text = static::color($text, $foreground, $background); } @@ -457,7 +457,7 @@ public static function print(string $text = '', ?string $foreground = null, ?str */ public static function write(string $text = '', ?string $foreground = null, ?string $background = null) { - if ($foreground || $background) { + if ((string) $foreground !== '' || (string) $background !== '') { $text = static::color($text, $foreground, $background); } @@ -480,7 +480,7 @@ public static function error(string $text, string $foreground = 'light_red', ?st $stdout = static::$isColored; static::$isColored = static::hasColorSupport(STDERR); - if ($foreground || $background) { + if ($foreground !== '' || (string) $background !== '') { $text = static::color($text, $foreground, $background); } @@ -589,7 +589,7 @@ public static function color(string $text, string $foreground, ?string $backgrou throw CLIException::forInvalidColor('foreground', $foreground); } - if ($background !== null && ! array_key_exists($background, static::$background_colors)) { + if ((string) $background !== '' && ! array_key_exists($background, static::$background_colors)) { throw CLIException::forInvalidColor('background', $background); } @@ -637,7 +637,7 @@ private static function getColoredText(string $text, string $foreground, ?string { $string = "\033[" . static::$foreground_colors[$foreground] . 'm'; - if ($background !== null) { + if ((string) $background !== '') { $string .= "\033[" . static::$background_colors[$background] . 'm'; } @@ -654,7 +654,7 @@ private static function getColoredText(string $text, string $foreground, ?string */ public static function strlen(?string $string): int { - if ($string === null) { + if ((string) $string === '') { return 0; } @@ -768,7 +768,7 @@ public static function generateDimensions() // Look for the next lines ending in ": " // Searching for "Columns:" or "Lines:" will fail on non-English locales - if ($return === 0 && $output && preg_match('/:\s*(\d+)\n[^:]+:\s*(\d+)\n/', implode("\n", $output), $matches)) { + if ($return === 0 && $output !== [] && preg_match('/:\s*(\d+)\n[^:]+:\s*(\d+)\n/', implode("\n", $output), $matches)) { static::$height = (int) $matches[1]; static::$width = (int) $matches[2]; } @@ -835,7 +835,7 @@ public static function showProgress($thisStep = 1, int $totalSteps = 10) */ public static function wrap(?string $string = null, int $max = 0, int $padLeft = 0): string { - if ($string === null || $string === '') { + if ((string) $string === '') { return ''; } diff --git a/system/Cache/Handlers/BaseHandler.php b/system/Cache/Handlers/BaseHandler.php index 43d316f87b0d..2e35864f5aba 100644 --- a/system/Cache/Handlers/BaseHandler.php +++ b/system/Cache/Handlers/BaseHandler.php @@ -67,7 +67,7 @@ public static function validateKey($key, $prefix = ''): string } $reserved = config(Cache::class)->reservedCharacters ?? self::RESERVED_CHARACTERS; - if ($reserved && strpbrk($key, $reserved) !== false) { + if ($reserved !== '' && strpbrk($key, $reserved) !== false) { throw new InvalidArgumentException('Cache key contains reserved characters ' . $reserved); } diff --git a/system/Cache/Handlers/PredisHandler.php b/system/Cache/Handlers/PredisHandler.php index 59e35aa4208f..fc0185033d64 100644 --- a/system/Cache/Handlers/PredisHandler.php +++ b/system/Cache/Handlers/PredisHandler.php @@ -19,6 +19,7 @@ use Exception; use Predis\Client; use Predis\Collection\Iterator\Keyspace; +use Predis\Response\Status; /** * Predis cache handler @@ -121,7 +122,7 @@ public function save(string $key, $value, int $ttl = 60) return false; } - if (! $this->redis->hmset($key, ['__ci_type' => $dataType, '__ci_value' => $value])) { + if (! $this->redis->hmset($key, ['__ci_type' => $dataType, '__ci_value' => $value]) instanceof Status) { return false; } diff --git a/system/Commands/Server/Serve.php b/system/Commands/Server/Serve.php index 82e58998a732..594e4e587e27 100644 --- a/system/Commands/Server/Serve.php +++ b/system/Commands/Server/Serve.php @@ -110,7 +110,7 @@ public function run(array $params) // to ensure our environment is set and it simulates basic mod_rewrite. passthru($php . ' -S ' . $host . ':' . $port . ' -t ' . $docroot . ' ' . $rewrite, $status); - if ($status && $this->portOffset < $this->tries) { + if ($status !== EXIT_SUCCESS && $this->portOffset < $this->tries) { $this->portOffset++; $this->run($params); diff --git a/system/Commands/Utilities/Routes.php b/system/Commands/Utilities/Routes.php index 9adcc1bc39e7..a0f81f6b42a0 100644 --- a/system/Commands/Utilities/Routes.php +++ b/system/Commands/Utilities/Routes.php @@ -86,7 +86,7 @@ public function run(array $params) $host = $params['host'] ?? null; // Set HTTP_HOST - if ($host) { + if ($host !== null) { $request = service('request'); $_SERVER = $request->getServer(); $_SERVER['HTTP_HOST'] = $host; @@ -96,7 +96,7 @@ public function run(array $params) $collection = service('routes')->loadRoutes(); // Reset HTTP_HOST - if ($host) { + if ($host !== null) { unset($_SERVER['HTTP_HOST']); } @@ -139,7 +139,9 @@ public function run(array $params) $autoRoutes = $autoRouteCollector->get(); // Check for Module Routes. - if ($routingConfig = config(Routing::class)) { + $routingConfig = config(Routing::class); + + if ($routingConfig instanceof Routing) { foreach ($routingConfig->moduleRoutes as $uri => $namespace) { $autoRouteCollector = new AutoRouteCollectorImproved( $namespace, @@ -188,7 +190,7 @@ public function run(array $params) usort($tbody, static fn ($handler1, $handler2) => strcmp($handler1[3], $handler2[3])); } - if ($host) { + if ($host !== null) { CLI::write('Host: ' . $host); } diff --git a/system/Common.php b/system/Common.php index 85db03f2870c..b647c9d247ad 100644 --- a/system/Common.php +++ b/system/Common.php @@ -441,7 +441,7 @@ function esc($data, string $context = 'html', ?string $encoding = null) $escaper = new Escaper($encoding); } - if ($encoding && $escaper->getEncoding() !== $encoding) { + if ($encoding !== null && $escaper->getEncoding() !== $encoding) { $escaper = new Escaper($encoding); } @@ -739,13 +739,13 @@ function lang(string $line, array $args = [], ?string $locale = null) // Get active locale $activeLocale = $language->getLocale(); - if ($locale && $locale !== $activeLocale) { + if ((string) $locale !== '' && $locale !== $activeLocale) { $language->setLocale($locale); } $lines = $language->getLine($line, $args); - if ($locale && $locale !== $activeLocale) { + if ((string) $locale !== '' && $locale !== $activeLocale) { // Reset to active locale $language->setLocale($activeLocale); } @@ -849,7 +849,7 @@ function redirect(?string $route = null): RedirectResponse { $response = service('redirectresponse'); - if ($route !== null) { + if ((string) $route !== '') { return $response->route($route); } diff --git a/system/Database/Forge.php b/system/Database/Forge.php index d2cfde6bf104..fc9aa54ec169 100644 --- a/system/Database/Forge.php +++ b/system/Database/Forge.php @@ -650,7 +650,7 @@ public function dropTable(string $tableName, bool $ifExists = false, bool $casca return false; } - if ($this->db->DBPrefix && str_starts_with($tableName, $this->db->DBPrefix)) { + if ($this->db->DBPrefix !== '' && str_starts_with($tableName, $this->db->DBPrefix)) { $tableName = substr($tableName, strlen($this->db->DBPrefix)); } diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index cf736171a7cf..4a39f13562e8 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -389,7 +389,7 @@ public function force(string $path, string $namespace, ?string $group = null) */ public function findMigrations(): array { - $namespaces = $this->namespace ? [$this->namespace] : array_keys(service('autoloader')->getNamespace()); + $namespaces = $this->namespace !== null ? [$this->namespace] : array_keys(service('autoloader')->getNamespace()); $migrations = []; foreach ($namespaces as $namespace) { @@ -524,7 +524,7 @@ protected function getMigrationNumber(string $migration): string { preg_match($this->regex, $migration, $matches); - return count($matches) ? $matches[1] : '0'; + return $matches !== [] ? $matches[1] : '0'; } /** @@ -539,7 +539,7 @@ protected function getMigrationName(string $migration): string { preg_match($this->regex, $migration, $matches); - return count($matches) ? $matches[2] : ''; + return $matches !== [] ? $matches[2] : ''; } /** @@ -645,7 +645,7 @@ public function getHistory(string $group = 'default'): array } // If a namespace was specified then use it - if ($this->namespace) { + if ($this->namespace !== null) { $builder->where('namespace', $this->namespace); } @@ -700,7 +700,7 @@ public function getLastBatch(): int ->get() ->getResultObject(); - $batch = is_array($batch) && count($batch) + $batch = is_array($batch) && $batch !== [] ? end($batch)->batch : 0; @@ -725,7 +725,7 @@ public function getBatchStart(int $batch): string ->get() ->getResultObject(); - return count($migration) ? $migration[0]->version : '0'; + return $migration !== [] ? $migration[0]->version : '0'; } /** diff --git a/system/Database/MySQLi/Connection.php b/system/Database/MySQLi/Connection.php index b40db946894d..f98f51fb3e19 100644 --- a/system/Database/MySQLi/Connection.php +++ b/system/Database/MySQLi/Connection.php @@ -193,7 +193,7 @@ public function connect(bool $persistent = false) $clientFlags )) { // Prior to version 5.7.3, MySQL silently downgrades to an unencrypted connection if SSL setup fails - if (($clientFlags & MYSQLI_CLIENT_SSL) && version_compare($this->mysqli->client_info, 'mysqlnd 5.7.3', '<=') + if (($clientFlags & MYSQLI_CLIENT_SSL) !== 0 && version_compare($this->mysqli->client_info, 'mysqlnd 5.7.3', '<=') && empty($this->mysqli->query("SHOW STATUS LIKE 'ssl_cipher'")->fetch_object()->Value) ) { $this->mysqli->close(); @@ -395,7 +395,7 @@ protected function _listTables(bool $prefixLimit = false, ?string $tableName = n { $sql = 'SHOW TABLES FROM ' . $this->escapeIdentifier($this->database); - if ($tableName !== null) { + if ((string) $tableName !== '') { return $sql . ' LIKE ' . $this->escape($tableName); } @@ -462,7 +462,9 @@ protected function _indexData(string $table): array throw new DatabaseException(lang('Database.failGetIndexData')); } - if (! $indexes = $query->getResultArray()) { + $indexes = $query->getResultArray(); + + if ($indexes === []) { return []; } diff --git a/system/Database/SQLite3/Connection.php b/system/Database/SQLite3/Connection.php index a1a03eff61f5..577e4b24ab76 100644 --- a/system/Database/SQLite3/Connection.php +++ b/system/Database/SQLite3/Connection.php @@ -89,7 +89,7 @@ public function connect(bool $persistent = false) $this->database = WRITEPATH . $this->database; } - $sqlite = (! $this->password) + $sqlite = (! isset($this->password) || $this->password !== '') ? new SQLite3($this->database) : new SQLite3($this->database, SQLITE3_OPEN_READWRITE | SQLITE3_OPEN_CREATE, $this->password); @@ -194,7 +194,7 @@ protected function _escapeString(string $str): string */ protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string { - if ($tableName !== null) { + if ((string) $tableName !== '') { return 'SELECT "NAME" FROM "SQLITE_MASTER" WHERE "TYPE" = \'table\'' . ' AND "NAME" NOT LIKE \'sqlite!_%\' ESCAPE \'!\'' . ' AND "NAME" LIKE ' . $this->escape($tableName); diff --git a/system/Email/Email.php b/system/Email/Email.php index b82779eb891d..51f610f6556c 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -485,7 +485,7 @@ public function setFrom($from, $name = '', $returnPath = null) if ($this->validate) { $this->validateEmail($this->stringToArray($from)); - if ($returnPath) { + if ($returnPath !== null) { $this->validateEmail($this->stringToArray($returnPath)); } } @@ -1233,7 +1233,9 @@ protected function buildMessage() $this->headerStr .= $hdr; } - static::strlen($body) && $body .= $this->newline . $this->newline; + if (static::strlen($body) > 0) { + $body .= $this->newline . $this->newline; + } $body .= $this->getMimeMessage() . $this->newline . $this->newline . '--' . $lastBoundary . $this->newline diff --git a/system/Encryption/Handlers/OpenSSLHandler.php b/system/Encryption/Handlers/OpenSSLHandler.php index f3b62c64a498..9745160b8003 100644 --- a/system/Encryption/Handlers/OpenSSLHandler.php +++ b/system/Encryption/Handlers/OpenSSLHandler.php @@ -82,7 +82,7 @@ class OpenSSLHandler extends BaseHandler public function encrypt($data, $params = null) { // Allow key override - if ($params) { + if ($params !== null) { $this->key = is_array($params) && isset($params['key']) ? $params['key'] : $params; } @@ -118,7 +118,7 @@ public function encrypt($data, $params = null) public function decrypt($data, $params = null) { // Allow key override - if ($params) { + if ($params !== null) { $this->key = is_array($params) && isset($params['key']) ? $params['key'] : $params; } diff --git a/system/Filters/Filters.php b/system/Filters/Filters.php index 1255e0c4055d..fd252fe1fa26 100644 --- a/system/Filters/Filters.php +++ b/system/Filters/Filters.php @@ -557,7 +557,7 @@ public function enableFilters(array $names, string $when = 'before') */ public function getArguments(?string $key = null) { - return $key === null ? $this->arguments : $this->arguments[$key]; + return ((string) $key === '') ? $this->arguments : $this->arguments[$key]; } // -------------------------------------------------------------------- @@ -674,7 +674,7 @@ protected function processMethods() */ protected function processFilters(?string $uri = null) { - if (! isset($this->config->filters) || ! $this->config->filters) { + if (! isset($this->config->filters) || $this->config->filters === []) { return; } diff --git a/system/HTTP/Files/FileCollection.php b/system/HTTP/Files/FileCollection.php index 079d5e73114f..add2c3c03f9c 100644 --- a/system/HTTP/Files/FileCollection.php +++ b/system/HTTP/Files/FileCollection.php @@ -253,7 +253,7 @@ protected function getValueDotNotationSyntax(array $index, array $value) { $currentIndex = array_shift($index); - if (isset($currentIndex) && is_array($index) && $index && is_array($value[$currentIndex]) && $value[$currentIndex]) { + if (isset($currentIndex) && is_array($index) && $index !== [] && array_key_exists($currentIndex, $value) && is_array($value[$currentIndex])) { return $this->getValueDotNotationSyntax($index, $value[$currentIndex]); } diff --git a/system/HTTP/OutgoingRequest.php b/system/HTTP/OutgoingRequest.php index 27e473a59ad1..e62f07241558 100644 --- a/system/HTTP/OutgoingRequest.php +++ b/system/HTTP/OutgoingRequest.php @@ -64,7 +64,7 @@ private function getHostFromUri(URI $uri): string { $host = $uri->getHost(); - return $host . ($uri->getPort() ? ':' . $uri->getPort() : ''); + return $host . ($uri->getPort() > 0 ? ':' . $uri->getPort() : ''); } /** diff --git a/system/HTTP/RedirectResponse.php b/system/HTTP/RedirectResponse.php index c8c76607b651..206b1de07c67 100644 --- a/system/HTTP/RedirectResponse.php +++ b/system/HTTP/RedirectResponse.php @@ -115,9 +115,8 @@ private function withErrors(): self { $validation = service('validation'); - if ($validation->getErrors()) { - $session = service('session'); - $session->setFlashdata('_ci_validation_errors', $validation->getErrors()); + if ($validation->getErrors() !== []) { + service('session')->setFlashdata('_ci_validation_errors', $validation->getErrors()); } return $this; diff --git a/system/HTTP/RequestTrait.php b/system/HTTP/RequestTrait.php index 51de3ea5c0fc..dfa4b663dbaf 100644 --- a/system/HTTP/RequestTrait.php +++ b/system/HTTP/RequestTrait.php @@ -59,7 +59,7 @@ trait RequestTrait */ public function getIPAddress(): string { - if ($this->ipAddress) { + if ($this->ipAddress !== '') { return $this->ipAddress; } diff --git a/system/HTTP/ResponseTrait.php b/system/HTTP/ResponseTrait.php index 45f07d186170..97ef4927d35c 100644 --- a/system/HTTP/ResponseTrait.php +++ b/system/HTTP/ResponseTrait.php @@ -123,18 +123,21 @@ public function setDate(DateTime $date) */ public function setLink(PagerInterface $pager) { - $links = ''; + $links = ''; + $previous = $pager->getPreviousPageURI(); - if ($previous = $pager->getPreviousPageURI()) { + if (is_string($previous) && $previous !== '') { $links .= '<' . $pager->getPageURI($pager->getFirstPage()) . '>; rel="first",'; $links .= '<' . $previous . '>; rel="prev"'; } - if (($next = $pager->getNextPageURI()) && $previous) { + $next = $pager->getNextPageURI(); + + if (is_string($next) && $next !== '' && is_string($previous) && $previous !== '') { $links .= ','; } - if ($next) { + if (is_string($next) && $next !== '') { $links .= '<' . $next . '>; rel="next",'; $links .= '<' . $pager->getPageURI($pager->getLastPage()) . '>; rel="last"'; } diff --git a/system/HTTP/UserAgent.php b/system/HTTP/UserAgent.php index 6a5104779a92..ec4d17438284 100644 --- a/system/HTTP/UserAgent.php +++ b/system/HTTP/UserAgent.php @@ -125,7 +125,7 @@ public function isBrowser(?string $key = null): bool } // No need to be specific, it's a browser - if ($key === null) { + if ((string) $key === '') { return true; } @@ -143,7 +143,7 @@ public function isRobot(?string $key = null): bool } // No need to be specific, it's a robot - if ($key === null) { + if ((string) $key === '') { return true; } @@ -161,7 +161,7 @@ public function isMobile(?string $key = null): bool } // No need to be specific, it's a mobile - if ($key === null) { + if ((string) $key === '') { return true; } @@ -289,7 +289,7 @@ protected function compileData() */ protected function setPlatform(): bool { - if (is_array($this->config->platforms) && $this->config->platforms) { + if (is_array($this->config->platforms) && $this->config->platforms !== []) { foreach ($this->config->platforms as $key => $val) { if (preg_match('|' . preg_quote($key, '|') . '|i', $this->agent)) { $this->platform = $val; @@ -309,7 +309,7 @@ protected function setPlatform(): bool */ protected function setBrowser(): bool { - if (is_array($this->config->browsers) && $this->config->browsers) { + if (is_array($this->config->browsers) && $this->config->browsers !== []) { foreach ($this->config->browsers as $key => $val) { if (preg_match('|' . $key . '.*?([0-9\.]+)|i', $this->agent, $match)) { $this->isBrowser = true; @@ -330,7 +330,7 @@ protected function setBrowser(): bool */ protected function setRobot(): bool { - if (is_array($this->config->robots) && $this->config->robots) { + if (is_array($this->config->robots) && $this->config->robots !== []) { foreach ($this->config->robots as $key => $val) { if (preg_match('|' . preg_quote($key, '|') . '|i', $this->agent)) { $this->isRobot = true; @@ -350,7 +350,7 @@ protected function setRobot(): bool */ protected function setMobile(): bool { - if (is_array($this->config->mobiles) && $this->config->mobiles) { + if (is_array($this->config->mobiles) && $this->config->mobiles !== []) { foreach ($this->config->mobiles as $key => $val) { if (false !== (stripos($this->agent, $key))) { $this->isMobile = true; diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index 58cd828e3faa..c3e2c83de0a6 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -788,7 +788,7 @@ function parse_form_attributes($attributes, array $default): string if (! is_bool($val)) { if ($key === 'value') { $val = esc($val); - } elseif ($key === 'name' && ! strlen($default['name'])) { + } elseif ($key === 'name' && $default['name'] === '') { continue; } $att .= $key . '="' . $val . '"' . ($key === array_key_last($default) ? '' : ' '); diff --git a/system/Helpers/text_helper.php b/system/Helpers/text_helper.php index 3de105736f57..dcc21126a5e5 100644 --- a/system/Helpers/text_helper.php +++ b/system/Helpers/text_helper.php @@ -741,7 +741,7 @@ function excerpt(string $text, ?string $phrase = null, int $radius = 100, string $count = ++$count + strlen($s); } - $ellPre = $phrase ? $ellipsis : ''; + $ellPre = $phrase !== null ? $ellipsis : ''; return str_replace(' ', ' ', $ellPre . $prev . $phrase . $post . $ellipsis); } diff --git a/system/HotReloader/HotReloader.php b/system/HotReloader/HotReloader.php index 6dfd0fcf66a9..305e641af04e 100644 --- a/system/HotReloader/HotReloader.php +++ b/system/HotReloader/HotReloader.php @@ -37,7 +37,7 @@ public function run(): void $appHash = $hasher->hash(); while (true) { - if (connection_status() !== CONNECTION_NORMAL || connection_aborted()) { + if (connection_status() !== CONNECTION_NORMAL || connection_aborted() === 1) { break; } @@ -50,6 +50,7 @@ public function run(): void $this->sendEvent('reload', ['time' => date('Y-m-d H:i:s')]); break; } + if (mt_rand(1, 10) > 8) { $this->sendEvent('ping', ['time' => date('Y-m-d H:i:s')]); } diff --git a/system/Model.php b/system/Model.php index fb1ebceda516..98e3be0b1f68 100644 --- a/system/Model.php +++ b/system/Model.php @@ -317,13 +317,13 @@ protected function doFirst() if ($this->tempUseSoftDeletes) { $builder->where($this->table . '.' . $this->deletedField, null); - } elseif ($this->useSoftDeletes && ($builder->QBGroupBy === []) && $this->primaryKey) { + } elseif ($this->useSoftDeletes && ($builder->QBGroupBy === []) && $this->primaryKey !== '') { $builder->groupBy($this->table . '.' . $this->primaryKey); } // Some databases, like PostgreSQL, need order // information to consistently return correct results. - if ($builder->QBGroupBy && ($builder->QBOrderBy === []) && $this->primaryKey) { + if ($builder->QBGroupBy !== [] && ($builder->QBOrderBy === []) && $this->primaryKey !== '') { $builder->orderBy($this->table . '.' . $this->primaryKey, 'asc'); } @@ -443,7 +443,7 @@ protected function doUpdate($id = null, $row = null): bool $builder = $this->builder(); - if ($id) { + if (! in_array($id, [null, '', 0, '0', []], true)) { $builder = $builder->whereIn($this->table . '.' . $this->primaryKey, $id); } @@ -496,7 +496,7 @@ protected function doDelete($id = null, bool $purge = false) $set = []; $builder = $this->builder(); - if ($id) { + if (! in_array($id, [null, '', 0, '0', []], true)) { $builder = $builder->whereIn($this->primaryKey, $id); } @@ -690,7 +690,7 @@ public function builder(?string $table = null) // Check for an existing Builder if ($this->builder instanceof BaseBuilder) { // Make sure the requested table matches the builder - if ($table && $this->builder->getTable() !== $table) { + if ((string) $table !== '' && $this->builder->getTable() !== $table) { return $this->db->table($table); } @@ -704,7 +704,7 @@ public function builder(?string $table = null) throw ModelException::forNoPrimaryKey(static::class); } - $table = ($table === null || $table === '') ? $this->table : $table; + $table = ((string) $table === '') ? $this->table : $table; // Ensure we have a good db connection if (! $this->db instanceof BaseConnection) { diff --git a/system/RESTful/BaseResource.php b/system/RESTful/BaseResource.php index 0360bdb12fc5..f2e171c8319e 100644 --- a/system/RESTful/BaseResource.php +++ b/system/RESTful/BaseResource.php @@ -61,7 +61,7 @@ public function initController(RequestInterface $request, ResponseInterface $res */ public function setModel($which = null) { - if ($which) { + if ($which !== null) { $this->model = is_object($which) ? $which : null; $this->modelName = is_object($which) ? null : $which; } diff --git a/system/Router/AutoRouter.php b/system/Router/AutoRouter.php index bb47bf96c89a..ce40f5cdc406 100644 --- a/system/Router/AutoRouter.php +++ b/system/Router/AutoRouter.php @@ -105,7 +105,7 @@ public function getRoute(string $uri, string $httpVerb): array if ($httpVerb !== 'CLI') { $controller = '\\' . $this->defaultNamespace; - $controller .= $this->directory ? str_replace('/', '\\', $this->directory) : ''; + $controller .= $this->directory !== null ? str_replace('/', '\\', $this->directory) : ''; $controller .= $controllerName; $controller = strtolower($controller); @@ -244,7 +244,7 @@ private function isValidSegment(string $segment): bool */ public function setDirectory(?string $dir = null, bool $append = false, bool $validate = true) { - if ($dir === null || $dir === '') { + if ((string) $dir === '') { $this->directory = null; return; @@ -260,7 +260,7 @@ public function setDirectory(?string $dir = null, bool $append = false, bool $va } } - if (! $append || ($this->directory === null || $this->directory === '')) { + if (! $append || ((string) $this->directory === '')) { $this->directory = trim($dir, '/') . '/'; } else { $this->directory .= trim($dir, '/') . '/'; @@ -275,7 +275,7 @@ public function setDirectory(?string $dir = null, bool $append = false, bool $va */ public function directory(): string { - return ($this->directory !== null && $this->directory !== '') ? $this->directory : ''; + return ((string) $this->directory !== '') ? $this->directory : ''; } private function controllerName(): string diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index ad5c01a4858f..2dbaba05e4cd 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -560,7 +560,7 @@ public function shouldAutoRoute(): bool */ public function getRoutes(?string $verb = null, bool $includeWildcard = true): array { - if ($verb === null || $verb === '') { + if ((string) $verb === '') { $verb = $this->getHTTPVerb(); } @@ -609,7 +609,7 @@ public function getRoutesOptions(?string $from = null, ?string $verb = null): ar { $options = $this->loadRoutesOptions($verb); - return $from ? $options[$from] ?? [] : $options; + return ((string) $from !== '') ? $options[$from] ?? [] : $options; } /** @@ -779,7 +779,7 @@ public function group(string $name, ...$params) $callback = array_pop($params); - if ($params && is_array($params[0])) { + if ($params !== [] && is_array($params[0])) { $options = array_shift($params); if (isset($options['filter'])) { @@ -1416,14 +1416,14 @@ private function replaceLocale(string $route, ?string $locale = null): string } // Check invalid locale - if ($locale !== null) { + if ((string) $locale !== '') { $config = config(App::class); if (! in_array($locale, $config->supportedLocales, true)) { $locale = null; } } - if ($locale === null) { + if ((string) $locale === '') { $locale = service('request')->getLocale(); } diff --git a/system/Session/Handlers/Database/PostgreHandler.php b/system/Session/Handlers/Database/PostgreHandler.php index b92ab1e57323..e999f356decd 100644 --- a/system/Session/Handlers/Database/PostgreHandler.php +++ b/system/Session/Handlers/Database/PostgreHandler.php @@ -75,7 +75,7 @@ public function gc($max_lifetime) protected function lockSession(string $sessionID): bool { $arg = "hashtext('{$sessionID}')" . ($this->matchIP ? ", hashtext('{$this->ipAddress}')" : ''); - if ($this->db->simpleQuery("SELECT pg_advisory_lock({$arg})")) { + if ($this->db->simpleQuery("SELECT pg_advisory_lock({$arg})") !== false) { $this->lock = $arg; return true; @@ -93,7 +93,7 @@ protected function releaseLock(): bool return true; } - if ($this->db->simpleQuery("SELECT pg_advisory_unlock({$this->lock})")) { + if ($this->db->simpleQuery("SELECT pg_advisory_unlock({$this->lock})") !== false) { $this->lock = false; return true; diff --git a/system/Session/Handlers/MemcachedHandler.php b/system/Session/Handlers/MemcachedHandler.php index 79bb4ca4613f..83a5d334ed85 100644 --- a/system/Session/Handlers/MemcachedHandler.php +++ b/system/Session/Handlers/MemcachedHandler.php @@ -267,7 +267,7 @@ protected function lockSession(string $sessionID): bool $attempt = 0; do { - if ($this->memcached->get($lockKey)) { + if ($this->memcached->get($lockKey) !== false) { sleep(1); continue; diff --git a/system/Test/CIUnitTestCase.php b/system/Test/CIUnitTestCase.php index 62c0fff83844..9e82ddb4f6dd 100644 --- a/system/Test/CIUnitTestCase.php +++ b/system/Test/CIUnitTestCase.php @@ -238,7 +238,7 @@ protected function setUp(): void { parent::setUp(); - if (! $this->app) { + if (! $this->app instanceof CodeIgniter) { $this->app = $this->createApplication(); } diff --git a/system/Test/FeatureTestTrait.php b/system/Test/FeatureTestTrait.php index 083313dfa7e2..13522d8758f3 100644 --- a/system/Test/FeatureTestTrait.php +++ b/system/Test/FeatureTestTrait.php @@ -189,7 +189,9 @@ public function call(string $method, string $path, ?array $params = null) $request = $this->setRequestBody($request, $params); // Initialize the RouteCollection - if (! $routes = $this->routes) { + $routes = $this->routes; + + if ($routes !== []) { $routes = service('routes')->loadRoutes(); } diff --git a/system/Test/FilterTestTrait.php b/system/Test/FilterTestTrait.php index 5837e6e658a6..d004ec22c5c1 100644 --- a/system/Test/FilterTestTrait.php +++ b/system/Test/FilterTestTrait.php @@ -221,7 +221,9 @@ protected function getFiltersForRoute(string $route, string $position): array $this->filters->reset(); - if ($routeFilters = $this->collection->getFiltersForRoute($route)) { + $routeFilters = $this->collection->getFiltersForRoute($route); + + if ($routeFilters !== []) { $this->filters->enableFilters($routeFilters, $position); } diff --git a/system/Traits/ConditionalTrait.php b/system/Traits/ConditionalTrait.php index c927a6815a8d..a778e9375a36 100644 --- a/system/Traits/ConditionalTrait.php +++ b/system/Traits/ConditionalTrait.php @@ -29,9 +29,9 @@ trait ConditionalTrait */ public function when($condition, callable $callback, ?callable $defaultCallback = null): self { - if ($condition) { + if ($condition !== '' && $condition !== false && $condition !== null) { $callback($this, $condition); - } elseif ($defaultCallback) { + } elseif ($defaultCallback !== null) { $defaultCallback($this); } @@ -52,9 +52,9 @@ public function when($condition, callable $callback, ?callable $defaultCallback */ public function whenNot($condition, callable $callback, ?callable $defaultCallback = null): self { - if (! $condition) { + if ($condition === '' || $condition === null || $condition === false || $condition === '0') { $callback($this, $condition); - } elseif ($defaultCallback) { + } elseif ($defaultCallback !== null) { $defaultCallback($this); } diff --git a/system/Validation/FileRules.php b/system/Validation/FileRules.php index 78d0ce521809..058b15739eef 100644 --- a/system/Validation/FileRules.php +++ b/system/Validation/FileRules.php @@ -52,7 +52,9 @@ public function __construct(?RequestInterface $request = null) */ public function uploaded(?string $blank, string $name): bool { - if (! ($files = $this->request->getFileMultiple($name))) { + $files = $this->request->getFileMultiple($name); + + if ($files === [] || $files === null) { $files = [$this->request->getFile($name)]; } @@ -86,12 +88,15 @@ public function max_size(?string $blank, string $params): bool // Grab the file name off the top of the $params // after we split it. $paramArray = explode(',', $params); + if (count($paramArray) !== 2) { throw new InvalidArgumentException('Invalid max_size parameter: "' . $params . '"'); } - $name = array_shift($paramArray); - if (! ($files = $this->request->getFileMultiple($name))) { + $name = array_shift($paramArray); + $files = $this->request->getFileMultiple($name); + + if ($files === [] || $files === null) { $files = [$this->request->getFile($name)]; } @@ -126,8 +131,9 @@ public function is_image(?string $blank, string $params): bool // after we split it. $params = explode(',', $params); $name = array_shift($params); + $files = $this->request->getFileMultiple($name); - if (! ($files = $this->request->getFileMultiple($name))) { + if ($files === [] || $files === null) { $files = [$this->request->getFile($name)]; } @@ -161,8 +167,9 @@ public function mime_in(?string $blank, string $params): bool // after we split it. $params = explode(',', $params); $name = array_shift($params); + $files = $this->request->getFileMultiple($name); - if (! ($files = $this->request->getFileMultiple($name))) { + if ($files === [] || $files === null) { $files = [$this->request->getFile($name)]; } @@ -192,8 +199,9 @@ public function ext_in(?string $blank, string $params): bool // after we split it. $params = explode(',', $params); $name = array_shift($params); + $files = $this->request->getFileMultiple($name); - if (! ($files = $this->request->getFileMultiple($name))) { + if ($files === [] || $files === null) { $files = [$this->request->getFile($name)]; } @@ -224,8 +232,9 @@ public function max_dims(?string $blank, string $params): bool // after we split it. $params = explode(',', $params); $name = array_shift($params); + $files = $this->request->getFileMultiple($name); - if (! ($files = $this->request->getFileMultiple($name))) { + if ($files === [] || $files === null) { $files = [$this->request->getFile($name)]; } diff --git a/system/View/Table.php b/system/View/Table.php index 60ccc509f9ae..9eb29578a6da 100644 --- a/system/View/Table.php +++ b/system/View/Table.php @@ -333,7 +333,7 @@ public function generate($tableData = null) $out = $this->template['table_open'] . $this->newline; // Add any caption here - if ($this->caption) { + if (isset($this->caption) && $this->caption !== '') { $out .= '' . $this->caption . '' . $this->newline; } diff --git a/tests/system/Email/EmailTest.php b/tests/system/Email/EmailTest.php index 99918122d8cf..389b657e573a 100644 --- a/tests/system/Email/EmailTest.php +++ b/tests/system/Email/EmailTest.php @@ -44,7 +44,7 @@ public static function provideEmailSendWithClearance(): iterable } /** - * @param mixed $autoClear + * @param bool $autoClear */ #[DataProvider('provideEmailSendWithClearance')] public function testEmailSendWithClearance($autoClear): void diff --git a/tests/system/Models/FindModelTest.php b/tests/system/Models/FindModelTest.php index b15857d4aaaf..43fb96d76b53 100644 --- a/tests/system/Models/FindModelTest.php +++ b/tests/system/Models/FindModelTest.php @@ -180,8 +180,8 @@ public function testFirst(): void } /** - * @param mixed $groupBy - * @param mixed $total + * @param bool $groupBy + * @param int $total */ #[DataProvider('provideFirstAggregate')] public function testFirstAggregate($groupBy, $total): void @@ -215,8 +215,8 @@ public static function provideFirstAggregate(): iterable } /** - * @param mixed $aggregate - * @param mixed $groupBy + * @param bool $aggregate + * @param bool $groupBy */ #[DataProvider('provideAggregateAndGroupBy')] public function testFirstRespectsSoftDeletes($aggregate, $groupBy): void @@ -260,8 +260,8 @@ public function testFirstRespectsSoftDeletes($aggregate, $groupBy): void } /** - * @param mixed $aggregate - * @param mixed $groupBy + * @param bool $aggregate + * @param bool $groupBy */ #[DataProvider('provideAggregateAndGroupBy')] public function testFirstRecoverTempUseSoftDeletes($aggregate, $groupBy): void diff --git a/utils/phpstan-baseline/booleanAnd.leftNotBoolean.neon b/utils/phpstan-baseline/booleanAnd.leftNotBoolean.neon deleted file mode 100644 index 856ad498e2e6..000000000000 --- a/utils/phpstan-baseline/booleanAnd.leftNotBoolean.neon +++ /dev/null @@ -1,63 +0,0 @@ -# total 12 errors - -parameters: - ignoreErrors: - - - message: '#^Only booleans are allowed in &&, array\|int\|string\|null given on the left side\.$#' - count: 1 - path: ../../system/BaseModel.php - - - - message: '#^Only booleans are allowed in &&, array\|string\|null given on the left side\.$#' - count: 1 - path: ../../system/CLI/CLI.php - - - - message: '#^Only booleans are allowed in &&, string given on the left side\.$#' - count: 1 - path: ../../system/Cache/Handlers/BaseHandler.php - - - - message: '#^Only booleans are allowed in &&, int given on the left side\.$#' - count: 1 - path: ../../system/Commands/Server/Serve.php - - - - message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#' - count: 3 - path: ../../system/Common.php - - - - message: '#^Only booleans are allowed in &&, string given on the left side\.$#' - count: 1 - path: ../../system/Database/Forge.php - - - - message: '#^Only booleans are allowed in &&, int given on the left side\.$#' - count: 1 - path: ../../system/Database/MySQLi/Connection.php - - - - message: '#^Only booleans are allowed in &&, int given on the left side\.$#' - count: 1 - path: ../../system/Email/Email.php - - - - message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#' - count: 1 - path: ../../system/HTTP/Response.php - - - - message: '#^Only booleans are allowed in &&, array given on the left side\.$#' - count: 1 - path: ../../system/Model.php - - - - message: '#^Only booleans are allowed in &&, string\|null given on the left side\.$#' - count: 1 - path: ../../system/Model.php - - - - message: '#^Only booleans are allowed in &&, array\ given on the left side\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php diff --git a/utils/phpstan-baseline/booleanAnd.rightNotBoolean.neon b/utils/phpstan-baseline/booleanAnd.rightNotBoolean.neon deleted file mode 100644 index 8be1c9e657d0..000000000000 --- a/utils/phpstan-baseline/booleanAnd.rightNotBoolean.neon +++ /dev/null @@ -1,43 +0,0 @@ -# total 8 errors - -parameters: - ignoreErrors: - - - message: '#^Only booleans are allowed in &&, array\ given on the right side\.$#' - count: 1 - path: ../../system/BaseModel.php - - - - message: '#^Only booleans are allowed in &&, list\ given on the right side\.$#' - count: 1 - path: ../../system/CLI/CLI.php - - - - message: '#^Only booleans are allowed in &&, int\<0, max\> given on the right side\.$#' - count: 1 - path: ../../system/Database/MigrationRunner.php - - - - message: '#^Only booleans are allowed in &&, string given on the right side\.$#' - count: 1 - path: ../../system/Email/Email.php - - - - message: '#^Only booleans are allowed in &&, array\ given on the right side\.$#' - count: 2 - path: ../../system/HTTP/Files/FileCollection.php - - - - message: '#^Only booleans are allowed in &&, string\|null given on the right side\.$#' - count: 1 - path: ../../system/HTTP/Response.php - - - - message: '#^Only booleans are allowed in &&, array\ given on the right side\.$#' - count: 4 - path: ../../system/HTTP/UserAgent.php - - - - message: '#^Only booleans are allowed in &&, string given on the right side\.$#' - count: 2 - path: ../../system/Model.php diff --git a/utils/phpstan-baseline/booleanNot.exprNotBoolean.neon b/utils/phpstan-baseline/booleanNot.exprNotBoolean.neon deleted file mode 100644 index 41a36091437c..000000000000 --- a/utils/phpstan-baseline/booleanNot.exprNotBoolean.neon +++ /dev/null @@ -1,68 +0,0 @@ -# total 13 errors - -parameters: - ignoreErrors: - - - message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#' - count: 1 - path: ../../system/Cache/Handlers/PredisHandler.php - - - - message: '#^Only booleans are allowed in a negated boolean, TWhenNot given\.$#' - count: 1 - path: ../../system/Database/BaseBuilder.php - - - - message: '#^Only booleans are allowed in a negated boolean, array given\.$#' - count: 1 - path: ../../system/Database/MySQLi/Connection.php - - - - message: '#^Only booleans are allowed in a negated boolean, string given\.$#' - count: 1 - path: ../../system/Database/SQLite3/Connection.php - - - - message: '#^Only booleans are allowed in a negated boolean, array\\>\> given\.$#' - count: 1 - path: ../../system/Filters/Filters.php - - - - message: '#^Only booleans are allowed in a negated boolean, int\<0, max\> given\.$#' - count: 1 - path: ../../system/Helpers/form_helper.php - - - - message: '#^Only booleans are allowed in a negated boolean, CodeIgniter\\CodeIgniter given\.$#' - count: 1 - path: ../../system/Test/CIUnitTestCase.php - - - - message: '#^Only booleans are allowed in a negated boolean, array\|null given\.$#' - count: 6 - path: ../../system/Validation/FileRules.php - - - - message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#' - count: 1 - path: ../../tests/system/Email/EmailTest.php - - - - message: '#^Only booleans are allowed in a negated boolean, CodeIgniter\\Router\\RouteCollection\|null given\.$#' - count: 1 - path: ../../tests/system/HomeTest.php - - - - message: '#^Only booleans are allowed in a negated boolean, mixed given\.$#' - count: 2 - path: ../../tests/system/Models/FindModelTest.php - - - - message: '#^Only booleans are allowed in a negated boolean, CodeIgniter\\Router\\RouteCollection\|null given\.$#' - count: 1 - path: ../../tests/system/Test/FeatureTestAutoRoutingImprovedTest.php - - - - message: '#^Only booleans are allowed in a negated boolean, CodeIgniter\\Router\\RouteCollection\|null given\.$#' - count: 1 - path: ../../tests/system/Test/FeatureTestTraitTest.php diff --git a/utils/phpstan-baseline/booleanOr.leftNotBoolean.neon b/utils/phpstan-baseline/booleanOr.leftNotBoolean.neon deleted file mode 100644 index bb6d0e1d3324..000000000000 --- a/utils/phpstan-baseline/booleanOr.leftNotBoolean.neon +++ /dev/null @@ -1,13 +0,0 @@ -# total 2 errors - -parameters: - ignoreErrors: - - - message: '#^Only booleans are allowed in \|\|, string given on the left side\.$#' - count: 1 - path: ../../system/CLI/CLI.php - - - - message: '#^Only booleans are allowed in \|\|, string\|null given on the left side\.$#' - count: 2 - path: ../../system/CLI/CLI.php diff --git a/utils/phpstan-baseline/booleanOr.rightNotBoolean.neon b/utils/phpstan-baseline/booleanOr.rightNotBoolean.neon deleted file mode 100644 index cca548646c48..000000000000 --- a/utils/phpstan-baseline/booleanOr.rightNotBoolean.neon +++ /dev/null @@ -1,18 +0,0 @@ -# total 3 errors - -parameters: - ignoreErrors: - - - message: '#^Only booleans are allowed in \|\|, string\|null given on the right side\.$#' - count: 3 - path: ../../system/CLI/CLI.php - - - - message: '#^Only booleans are allowed in \|\|, int given on the right side\.$#' - count: 1 - path: ../../system/HotReloader/HotReloader.php - - - - message: '#^Only booleans are allowed in \|\|, mixed given on the right side\.$#' - count: 1 - path: ../../tests/system/Models/FindModelTest.php diff --git a/utils/phpstan-baseline/codeigniter.superglobalAccessAssign.neon b/utils/phpstan-baseline/codeigniter.superglobalAccessAssign.neon index 2b08524179cb..4eae1fef60ee 100644 --- a/utils/phpstan-baseline/codeigniter.superglobalAccessAssign.neon +++ b/utils/phpstan-baseline/codeigniter.superglobalAccessAssign.neon @@ -3,7 +3,7 @@ parameters: ignoreErrors: - - message: '#^Assigning non\-falsy\-string directly on offset ''HTTP_HOST'' of \$_SERVER is discouraged\.$#' + message: '#^Assigning string directly on offset ''HTTP_HOST'' of \$_SERVER is discouraged\.$#' count: 1 path: ../../system/Commands/Utilities/Routes.php diff --git a/utils/phpstan-baseline/elseif.condNotBoolean.neon b/utils/phpstan-baseline/elseif.condNotBoolean.neon deleted file mode 100644 index 81f9d151f114..000000000000 --- a/utils/phpstan-baseline/elseif.condNotBoolean.neon +++ /dev/null @@ -1,8 +0,0 @@ -# total 1 error - -parameters: - ignoreErrors: - - - message: '#^Only booleans are allowed in an elseif condition, \(callable\)\|null given\.$#' - count: 2 - path: ../../system/Database/BaseBuilder.php diff --git a/utils/phpstan-baseline/if.condNotBoolean.neon b/utils/phpstan-baseline/if.condNotBoolean.neon index 3acc4f2b460b..6e9b4b56f3fb 100644 --- a/utils/phpstan-baseline/if.condNotBoolean.neon +++ b/utils/phpstan-baseline/if.condNotBoolean.neon @@ -1,4 +1,4 @@ -# total 17 errors +# total 1 error parameters: ignoreErrors: @@ -6,83 +6,3 @@ parameters: message: '#^Only booleans are allowed in an if condition, mixed given\.$#' count: 1 path: ../../system/CLI/CLI.php - - - - message: '#^Only booleans are allowed in an if condition, Config\\Routing given\.$#' - count: 1 - path: ../../system/Commands/Utilities/Routes.php - - - - message: '#^Only booleans are allowed in an if condition, string\|null given\.$#' - count: 3 - path: ../../system/Commands/Utilities/Routes.php - - - - message: '#^Only booleans are allowed in an if condition, TWhen given\.$#' - count: 1 - path: ../../system/Database/BaseBuilder.php - - - - message: '#^Only booleans are allowed in an if condition, string\|null given\.$#' - count: 1 - path: ../../system/Database/MigrationRunner.php - - - - message: '#^Only booleans are allowed in an if condition, string\|null given\.$#' - count: 1 - path: ../../system/Email/Email.php - - - - message: '#^Only booleans are allowed in an if condition, array\|string\|null given\.$#' - count: 2 - path: ../../system/Encryption/Handlers/OpenSSLHandler.php - - - - message: '#^Only booleans are allowed in an if condition, array\ given\.$#' - count: 1 - path: ../../system/HTTP/RedirectResponse.php - - - - message: '#^Only booleans are allowed in an if condition, string given\.$#' - count: 1 - path: ../../system/HTTP/Request.php - - - - message: '#^Only booleans are allowed in an if condition, string\|null given\.$#' - count: 2 - path: ../../system/HTTP/Response.php - - - - message: '#^Only booleans are allowed in an if condition, array\|int\|string\|null given\.$#' - count: 2 - path: ../../system/Model.php - - - - message: '#^Only booleans are allowed in an if condition, object\|string\|null given\.$#' - count: 1 - path: ../../system/RESTful/BaseResource.php - - - - message: '#^Only booleans are allowed in an if condition, mixed given\.$#' - count: 2 - path: ../../system/Session/Handlers/Database/PostgreHandler.php - - - - message: '#^Only booleans are allowed in an if condition, mixed given\.$#' - count: 1 - path: ../../system/Session/Handlers/MemcachedHandler.php - - - - message: '#^Only booleans are allowed in an if condition, string\|null given\.$#' - count: 1 - path: ../../system/View/Table.php - - - - message: '#^Only booleans are allowed in an if condition, mixed given\.$#' - count: 5 - path: ../../tests/system/Models/FindModelTest.php - - - - message: '#^Only booleans are allowed in an if condition, list\ given\.$#' - count: 1 - path: ../../tests/system/Test/FilterTestTraitTest.php diff --git a/utils/phpstan-baseline/loader.neon b/utils/phpstan-baseline/loader.neon index 1746fc32470a..789d5ef7e1ef 100644 --- a/utils/phpstan-baseline/loader.neon +++ b/utils/phpstan-baseline/loader.neon @@ -1,12 +1,7 @@ includes: - argument.type.neon - assign.propertyType.neon - - booleanAnd.leftNotBoolean.neon - booleanAnd.rightAlwaysTrue.neon - - booleanAnd.rightNotBoolean.neon - - booleanNot.exprNotBoolean.neon - - booleanOr.leftNotBoolean.neon - - booleanOr.rightNotBoolean.neon - class.notFound.neon - codeigniter.cacheHandlerInstance.neon - codeigniter.configArgumentInstanceof.neon @@ -18,7 +13,6 @@ includes: - codeigniter.superglobalAccessAssign.neon - codeigniter.unknownServiceMethod.neon - deadCode.unreachable.neon - - elseif.condNotBoolean.neon - empty.notAllowed.neon - empty.property.neon - expr.resultUnused.neon @@ -60,7 +54,6 @@ includes: - return.type.neon - return.unusedType.neon - staticMethod.notFound.neon - - ternary.condNotBoolean.neon - ternary.shortNotAllowed.neon - unset.offset.neon - varTag.type.neon diff --git a/utils/phpstan-baseline/ternary.condNotBoolean.neon b/utils/phpstan-baseline/ternary.condNotBoolean.neon deleted file mode 100644 index 97d5bc785dac..000000000000 --- a/utils/phpstan-baseline/ternary.condNotBoolean.neon +++ /dev/null @@ -1,43 +0,0 @@ -# total 8 errors - -parameters: - ignoreErrors: - - - message: '#^Only booleans are allowed in a ternary operator condition, array\|null given\.$#' - count: 1 - path: ../../system/BaseModel.php - - - - message: '#^Only booleans are allowed in a ternary operator condition, string\|null given\.$#' - count: 1 - path: ../../system/CLI/CLI.php - - - - message: '#^Only booleans are allowed in a ternary operator condition, int\<0, max\> given\.$#' - count: 3 - path: ../../system/Database/MigrationRunner.php - - - - message: '#^Only booleans are allowed in a ternary operator condition, string\|null given\.$#' - count: 1 - path: ../../system/Database/MigrationRunner.php - - - - message: '#^Only booleans are allowed in a ternary operator condition, int\|null given\.$#' - count: 1 - path: ../../system/HTTP/OutgoingRequest.php - - - - message: '#^Only booleans are allowed in a ternary operator condition, string\|null given\.$#' - count: 1 - path: ../../system/Helpers/text_helper.php - - - - message: '#^Only booleans are allowed in a ternary operator condition, string\|null given\.$#' - count: 1 - path: ../../system/Router/AutoRouter.php - - - - message: '#^Only booleans are allowed in a ternary operator condition, string\|null given\.$#' - count: 1 - path: ../../system/Router/RouteCollection.php