path = $path; $this->config = $config; $this->codebase = $codebase; } /** * @psalm-suppress PossiblyUnusedParam */ public function __invoke(Plugin\RegistrationInterface $registration, ?SimpleXMLElement $config = null): void { $fq_class_name = $this->getPluginClassForPath($this->path); /** @psalm-suppress UnresolvableInclude */ require_once($this->path); \assert(class_exists($fq_class_name)); $registration->registerHooksFromClass($fq_class_name); } private function getPluginClassForPath(string $path): string { $codebase = $this->codebase; $path = \str_replace(['/', '\\'], \DIRECTORY_SEPARATOR, $path); $file_storage = $codebase->createFileStorageForPath($path); $file_to_scan = new FileScanner($path, $this->config->shortenFileName($path), true); $file_to_scan->scan( $codebase, $file_storage ); $declared_classes = ClassLikeAnalyzer::getClassesForFile($codebase, $path); return reset($declared_classes); } }