getMiddlewareStack()); if ($lastSegment === null) { return null; } // Obtain the callable associated with the route. $callable = $lastSegment->getCallable(); $class = null; $method = null; // Handle array callable: [object|class-string, 'method'] if (is_array($callable) && count($callable) === 2) { [$class, $method] = $callable; } elseif (is_string($callable)) { // Handle string callable: 'ClassName::methodName' [$class, $method] = explode('::', $callable); } return [$class, $method]; } }