From 5caee6ae0bb0db27f441f1a2e6f6baac07c51eb8 Mon Sep 17 00:00:00 2001 From: Abdul Malik Ikhsan Date: Sat, 28 Dec 2024 00:21:21 +0700 Subject: [PATCH] refactor: more preg_match() and empty string only check --- system/Router/RouteCollection.php | 2 +- system/Test/CIUnitTestCase.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/system/Router/RouteCollection.php b/system/Router/RouteCollection.php index e86b0380e7c1..f33cf175a393 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 (in_array(preg_match('#^' . $pattern . '$#u', $params[$index]), [0, false], true)) { + if (preg_match('#^' . $pattern . '$#u', $params[$index]) !== 1) { throw RouterException::forInvalidParameterType(); } diff --git a/system/Test/CIUnitTestCase.php b/system/Test/CIUnitTestCase.php index faa1a0bd5fbe..394a289c8cff 100644 --- a/system/Test/CIUnitTestCase.php +++ b/system/Test/CIUnitTestCase.php @@ -374,7 +374,7 @@ public function assertLogContains(string $level, string $logMessage, string $mes { $this->assertTrue( TestLogger::didLog($level, $logMessage, false), - $message !== '' && $message !== '0' ? $message : sprintf( + $message !== '' ? $message : sprintf( 'Failed asserting that logs have a record of message containing "%s" with level "%s".', $logMessage, $level