/** * Process annotations from summary XML file * * @param string $path * @param string $summaryXml * @return void */ protected function processAnnotations($path, $summaryXml) { $doc = new \DOMDocument(); $doc->load($summaryXml); $xpath = new \DOMXPath($doc); // Add line numbers to all entities foreach ($xpath->query('//class') as $classNode) { $files = $classNode->getElementsByTagName('file'); if ($files->length === 0) { continue; } $file = $files->item(0)->getAttribute('name'); $processor = $this->factory->factory($file); $classNode->setAttribute('line', $processor->getLineForEntity($classNode->getAttribute('name'), 'class')); foreach ($classNode->getElementsByTagName('method') as $methodNode) { $methodNode->setAttribute('line', $processor->getLineForEntity($methodNode->getAttribute('name'), 'function')); } } // Replace all paths in summary.xml with relative paths foreach ($xpath->query('//file') as $fileNode) { $fileNode->setAttribute('name', str_replace($path, '', $fileNode->getAttribute('name'))); } $doc->save($summaryXml); $this->model->load($summaryXml); foreach ($this->model->getAnnotations() as $annotation) { $this->gateway->create($annotation); } }