diff --git a/system/CLI/CLI.php b/system/CLI/CLI.php index 185f51e3635c..8aa9854900eb 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 || $maxOptions < $maxInput) { + if ($pattern === 0 || $pattern === false || $maxOptions < $maxInput) { static::error('Please select correctly.'); CLI::newLine(); diff --git a/system/Database/MigrationRunner.php b/system/Database/MigrationRunner.php index 4a39f13562e8..13919c785372 100644 --- a/system/Database/MigrationRunner.php +++ b/system/Database/MigrationRunner.php @@ -450,7 +450,7 @@ protected function migrationFromFile(string $path, string $namespace) $filename = basename($path, '.php'); - if (! preg_match($this->regex, $filename)) { + if (preg_match($this->regex, $filename) !== 1) { return false; } diff --git a/system/Helpers/form_helper.php b/system/Helpers/form_helper.php index c3e2c83de0a6..7e11388841f4 100644 --- a/system/Helpers/form_helper.php +++ b/system/Helpers/form_helper.php @@ -62,7 +62,7 @@ function form_open(string $action = '', $attributes = [], array $hidden = []): s // Add CSRF field if enabled, but leave it out for GET requests and requests to external websites $before = service('filters')->getFilters()['before']; - if ((in_array('csrf', $before, true) || array_key_exists('csrf', $before)) && str_contains($action, base_url()) && ! stripos($form, 'method="get"')) { + if ((in_array('csrf', $before, true) || array_key_exists('csrf', $before)) && str_contains($action, base_url()) && stripos($form, 'method="get"') === false) { $form .= csrf_field($csrfId ?? null); } diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index 2dbaba05e4cd..13cbba449989 100644 --- a/system/Router/RouteCollection.php +++ b/system/Router/RouteCollection.php @@ -1329,7 +1329,7 @@ protected function fillRouteParams(string $from, ?array $params = null): string $patterns = $matches[0]; foreach ($patterns as $index => $pattern) { - if (! preg_match('#^' . $pattern . '$#u', $params[$index])) { + if (preg_match('#^' . $pattern . '$#u', $params[$index]) !== 1) { throw RouterException::forInvalidParameterType(); } @@ -1391,7 +1391,7 @@ protected function buildReverseRoute(string $from, array $params): string // or maybe $placeholder is not a placeholder, but a regex. $pattern = $this->placeholders[$placeholderName] ?? $placeholder; - if (! preg_match('#^' . $pattern . '$#u', (string) $params[$index])) { + if (preg_match('#^' . $pattern . '$#u', (string) $params[$index]) !== 1) { throw RouterException::forInvalidParameterType(); }