diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 9a7e1459e40f..fa77515e1ba8 100644 --- a/system/CLI/CLI.php +++ b/system/CLI/CLI.php @@ -348,7 +348,7 @@ public static function promptByMultipleKeys(string $text, array $options): array // return the prompt again if $input contain(s) non-numeric character, except a comma. // And if max from $options less than max from input, // it means user tried to access null value in $options - if ($pattern === 0 || $maxOptions < $maxInput) { + if ($pattern < 1 || $maxOptions < $maxInput) { static::error('Please select correctly.'); CLI::newLine(); diff --git a/system/Database/BaseBuilder.php b/system/Database/BaseBuilder.php index 54d9a8980f44..ca64800463a2 100644 --- a/system/Database/BaseBuilder.php +++ b/system/Database/BaseBuilder.php @@ -663,7 +663,7 @@ public function join(string $table, $cond, string $type = '', ?bool $escape = nu } else { // Split multiple conditions // @TODO This does not parse `BETWEEN a AND b` correctly. - if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE)) { + if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE) >= 1) { $conditions = []; $joints = $joints[0]; array_unshift($joints, ['', 0]); @@ -3470,7 +3470,7 @@ protected function getOperator(string $str, bool $list = false) '/' . implode('|', $this->pregOperators) . '/i', $str, $match - ) ? ($list ? $match[0] : $match[0][0]) : false; + ) >= 1 ? ($list ? $match[0] : $match[0][0]) : false; } /** @@ -3501,7 +3501,7 @@ private function getOperatorFromWhereKey(string $whereKey) '/' . implode('|', $pregOperators) . '/i', $whereKey, $match - ) ? $match[0] : false; + ) >= 1 ? $match[0] : false; } /** diff --git a/system/Database/Query.php b/system/Database/Query.php index 36026817d4d1..f0b75513c6b5 100644 --- a/system/Database/Query.php +++ b/system/Database/Query.php @@ -342,7 +342,7 @@ protected function matchNamedBinds(string $sql, array $binds): string */ protected function matchSimpleBinds(string $sql, array $binds, int $bindCount, int $ml): string { - if ($c = preg_match_all("/'[^']*'/", $sql, $matches)) { + if ($c = preg_match_all("/'[^']*'/", $sql, $matches) >= 1) { $c = preg_match_all('/' . preg_quote($this->bindMarker, '/') . '/i', str_replace($matches[0], str_replace($this->bindMarker, str_repeat(' ', $ml), $matches[0]), $sql, $c), $matches, PREG_OFFSET_CAPTURE); // Bind values' count must match the count of markers in the query diff --git a/system/Database/SQLSRV/Builder.php b/system/Database/SQLSRV/Builder.php index e320069e80bf..1aeaf0a4e6ee 100644 --- a/system/Database/SQLSRV/Builder.php +++ b/system/Database/SQLSRV/Builder.php @@ -122,7 +122,7 @@ public function join(string $table, $cond, string $type = '', ?bool $escape = nu $cond = ' ON ' . $cond; } else { // Split multiple conditions - if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE)) { + if (preg_match_all('/\sAND\s|\sOR\s/i', $cond, $joints, PREG_OFFSET_CAPTURE) >= 1) { $conditions = []; $joints = $joints[0]; array_unshift($joints, ['', 0]); diff --git a/system/Email/Email.php b/system/Email/Email.php index 5d420cc2e99c..c52c36230866 100644 --- a/system/Email/Email.php +++ b/system/Email/Email.php @@ -1031,7 +1031,7 @@ public function wordWrap($str, $charlim = null) $unwrap = []; - if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches)) { + if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches) >= 1) { for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { $unwrap[] = $matches[1][$i]; $str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str); diff --git a/system/Helpers/text_helper.php b/system/Helpers/text_helper.php index dcc21126a5e5..8733049c88a4 100644 --- a/system/Helpers/text_helper.php +++ b/system/Helpers/text_helper.php @@ -131,7 +131,7 @@ function ascii_to_entities(string $str): string */ function entities_to_ascii(string $str, bool $all = true): string { - if (preg_match_all('/\&#(\d+)\;/', $str, $matches)) { + if (preg_match_all('/\&#(\d+)\;/', $str, $matches) >= 1) { for ($i = 0, $s = count($matches[0]); $i < $s; $i++) { $digits = (int) $matches[1][$i]; $out = ''; @@ -195,7 +195,7 @@ function word_censor(string $str, array $censored, string $replacement = ''): st "\\1{$replacement}\\3", $str ); - } elseif (preg_match_all("/{$delim}(" . $badword . "){$delim}/i", $str, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE)) { + } elseif (preg_match_all("/{$delim}(" . $badword . "){$delim}/i", $str, $matches, PREG_PATTERN_ORDER | PREG_OFFSET_CAPTURE) >= 1) { $matches = $matches[1]; for ($i = count($matches) - 1; $i >= 0; $i--) { @@ -351,7 +351,7 @@ function word_wrap(string $str, int $charlim = 76): string // strip the entire chunk and replace it with a marker. $unwrap = []; - if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches)) { + if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches) >= 1) { for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { $unwrap[] = $matches[1][$i]; $str = str_replace($matches[0][$i], '{{unwrapped' . $i . '}}', $str); diff --git a/system/Helpers/url_helper.php b/system/Helpers/url_helper.php index 28bb2cf4c2a1..b6df3edc3c3d 100644 --- a/system/Helpers/url_helper.php +++ b/system/Helpers/url_helper.php @@ -360,7 +360,7 @@ function auto_link(string $str, string $type = 'both', bool $popup = false): str $str, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER - ) + ) >= 1 ) { // Set our target HTML if using popup links. $target = ($popup) ? ' target="_blank"' : ''; @@ -387,7 +387,7 @@ function auto_link(string $str, string $type = 'both', bool $popup = false): str $str, $matches, PREG_OFFSET_CAPTURE - ) + ) >= 1 ) { foreach (array_reverse($matches[0]) as $match) { if (filter_var($match[0], FILTER_VALIDATE_EMAIL) !== false) { diff --git a/system/Session/Handlers/MemcachedHandler.php b/system/Session/Handlers/MemcachedHandler.php index e651808a8ba8..73133e88d959 100644 --- a/system/Session/Handlers/MemcachedHandler.php +++ b/system/Session/Handlers/MemcachedHandler.php @@ -98,7 +98,7 @@ public function open($path, $name): bool $this->savePath, $matches, PREG_SET_ORDER - ) === 0 + ) < 1 ) { $this->memcached = null; $this->logger->error('Session: Invalid Memcached save path format: ' . $this->savePath); diff --git a/system/Typography/Typography.php b/system/Typography/Typography.php index 145ff68f1193..1dfca68c5164 100644 --- a/system/Typography/Typography.php +++ b/system/Typography/Typography.php @@ -96,7 +96,7 @@ public function autoTypography(string $str, bool $reduceLinebreaks = false): str // HTML comment tags don't conform to patterns of normal tags, so pull them out separately, only if needed $htmlComments = []; - if (str_contains($str, '