diff --git a/src/Active.php b/src/Active.php index 6cce521..f46db42 100644 --- a/src/Active.php +++ b/src/Active.php @@ -218,7 +218,7 @@ public function checkRoute($routeNames) * * @return bool */ - public function checkRoutePattern($patterns) + public function checkRoutePattern($patterns): bool { if (!$this->route) { return false; @@ -227,7 +227,7 @@ public function checkRoutePattern($patterns) $routeName = $this->route->getName(); if ($routeName == null) { - return in_array(null, $patterns); + return in_array(null, (array) $patterns); } foreach ((array)$patterns as $p) { diff --git a/tests/ActiveTest.php b/tests/ActiveTest.php index 34ad56b..2b105a1 100644 --- a/tests/ActiveTest.php +++ b/tests/ActiveTest.php @@ -421,6 +421,11 @@ public function provideCheckRoutePatternTestData() ['foo.*', null], true, ], + 'route with no name and single pattern' => [ + Request::create('/'), + 'foo.*', + false, + ], ]; }