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
 /**
  * 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 #3
0
 /**
  * Show project overview
  *
  * @param RMF\Request $request
  * @return Struct\Response
  */
 public function showOverview(RMF\Request $request)
 {
     $summaries = array();
     foreach ($this->analyzers as $id => $analyzer) {
         $summaries[] = $summary = $analyzer->getSummary();
         $summary->module = $id;
     }
     return new Struct\Response('overview.twig', array('navigation' => $this->getMenuEntries(), 'summaries' => $summaries, 'annotations' => $this->gateway->getAnnotationsStats(array('user'))));
 }
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);
     }
 }
Example #6
0
 /**
  * Show project overview
  *
  * @param RMF\Request $request
  * @return Struct\Response
  */
 public function show(RMF\Request $request)
 {
     $path = $request->variables['path'] ?: '/';
     $source = array();
     $annotations = array();
     $index = array();
     if (file_exists($file = $this->source . '/' . $path) && is_file($file)) {
         $processor = $this->factory->factory($file);
         $processor->addAnnotations($annotations = $this->gateway->getAnnotationsForFile($path));
         $source = $processor->getSourceData();
         $index = $processor->getIndex();
     }
     return new Struct\Response('source.twig', array('path' => $path, 'tree' => $this->getSourceTree($path), 'source' => $source, 'index' => $index, 'annotations' => $annotations, 'dependencies' => $this->getClassMetainformation($path)));
 }