routeCollection = $routeCollection; $this->controllerReflector = $controllerReflector; parent::__construct(function () { $whitelist = Analyser::$whitelist; Analyser::$whitelist = false; try { $options = ['processors' => $this->getProcessors()]; $annotation = \Swagger\scan($this->getFinder(), $options); return json_decode(json_encode($annotation)); } finally { Analyser::$whitelist = $whitelist; } }, $overwrite); } private function getFinder() { $files = []; foreach ($this->routeCollection->all() as $route) { if (!$route->hasDefault('_controller')) { continue; } // if able to resolve the controller $controller = $route->getDefault('_controller'); if ($callable = $this->controllerReflector->getReflectionClassAndMethod($controller)) { list($class, $method) = $callable; $files[$class->getFileName()] = true; } } $finder = new Finder(); $finder->append(array_keys($files)); return $finder; } private function getProcessors(): array { $processors = [ new AddDefaults(), new ModelRegister($this->modelRegistry), new OperationResolver($this->routeCollection, $this->controllerReflector), ]; return array_merge($processors, Analysis::processors()); } }