Example #1
0
 /**
  * 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);
     }
 }
Example #2
0
 /**
  * Annotate source file
  *
  * @param RMF\Request $request
  * @return Struct\Response
  */
 public function annotate(RMF\Request $request)
 {
     $default = array('file' => null, 'line' => null, 'character' => null, 'type' => 'user', 'class' => 'annotate', 'message' => null);
     $data = array_merge($default, $request->body);
     $this->gateway->create(new Struct\Annotation($data['file'], $data['line'], $data['character'], $data['type'], $data['class'], $data['message']));
     return false;
 }
Example #3
0
 /**
  * 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);
     // 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);
     // Find all metrics and emit signals for warnings and errors
     foreach ($xpath->query('//file') as $fileNode) {
         foreach ($fileNode->getElementsByTagName('error') as $violation) {
             $this->gateway->create(new Struct\Annotation($fileNode->getAttribute('name'), (int) $violation->getAttribute('line'), null, 'phplint', $violation->getAttribute('severity'), $violation->getAttribute('message')));
         }
     }
 }
Example #4
0
 /**
  * Process annotations from summary XML file
  *
  * @param string $path
  * @param string $summaryXml
  * @return void
  */
 protected function processAnnotations()
 {
     $annotations = $this->parseComments();
     foreach ($annotations as $file => $fileAnnotations) {
         foreach ($fileAnnotations as $annotation) {
             $this->gateway->create($annotation);
         }
     }
 }
Example #5
0
 /**
  * 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);
     // 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);
     foreach ($this->extractAnnotations($xpath) as $annotation) {
         $this->gateway->create($annotation);
     }
 }