public function checkController(Route $route, $uri) { if (!$route->getController()) { return true; } $path = $route->getPath(); $slice = substr($uri, strlen($path)); if (!$slice) { return false; } $filtered = array_filter(explode('/', $slice)); $action = reset($filtered); $action = preg_replace('~\\W~', '', (string) $action); if (!$action) { return false; } $controller = $route->getCallback(); try { $class = new ReflectionClass($controller); } catch (ReflectionException $e) { return false; } if (!$class->hasMethod($action)) { return false; } if (!$class->getMethod($action)->isPublic()) { return false; } $route->setCallback($controller . '::' . $class->getMethod($action)->getName()); return true; }