diff --git a/src/Exceptions/CouldntGetRouteDetails.php b/src/Exceptions/CouldntGetRouteDetails.php new file mode 100644 index 00000000..1e1cb478 --- /dev/null +++ b/src/Exceptions/CouldntGetRouteDetails.php @@ -0,0 +1,11 @@ +getRoute(); $routeControllerAndMethod = u::getRouteClassAndMethodNames($route); - if (!$this->isValidRoute($routeControllerAndMethod)) { + if (!$this->isValidRoute($routeControllerAndMethod, $route)) { c::warn('Skipping invalid route: ' . c::getRouteRepresentation($route)); continue; } @@ -217,9 +219,12 @@ protected function writeEndpointsToDisk(array $grouped): void } } - private function isValidRoute(array $routeControllerAndMethod = null): bool + private function isValidRoute(?array $routeControllerAndMethod, Route $route): bool { if (is_array($routeControllerAndMethod)) { + if (count($routeControllerAndMethod) < 2) { + throw CouldntGetRouteDetails::forRoute(c::getRouteRepresentation($route)); + } [$classOrObject, $method] = $routeControllerAndMethod; if (u::isInvokableObject($classOrObject)) { return true;