コード例 #1
0
 /**
  * @return array
  */
 private function parse()
 {
     if ($this->specification !== NULL) {
         return;
     }
     $queries = array();
     $states = array();
     foreach ($this->dom->query('states/state') as $state) {
         /** @var TheSeer\fDOM\fDOMElement $state */
         $states[$state->getAttribute('name')] = array('transitions' => array(), 'query' => $state->getAttribute('query'));
         $queries[] = $state->getAttribute('query');
     }
     $operations = array();
     foreach ($this->dom->query('operations/operation') as $operation) {
         /** @var TheSeer\fDOM\fDOMElement $operation */
         $operations[$operation->getAttribute('name')] = array('allowed' => $operation->getAttribute('allowed'), 'disallowed' => $operation->getAttribute('disallowed'));
     }
     foreach ($this->dom->query('transitions/transition') as $transition) {
         /** @var TheSeer\fDOM\fDOMElement $transition */
         $from = $transition->getAttribute('from');
         $to = $transition->getAttribute('to');
         $operation = $transition->getAttribute('operation');
         $states[$from]['transitions'][$operation] = $to;
     }
     $this->specification = array('operations' => $operations, 'queries' => $queries, 'states' => $states);
 }
コード例 #2
0
 /**
  * @covers \TheSeer\fDOM\fDOMDocument::nodeList2FragMent
  */
 public function testTransformNodeListToFragmentWorks()
 {
     $this->dom->loadXML('<?xml version="1.0" ?><root><node1/><node2 /></root>');
     $frag = $this->dom->nodeList2Fragment($this->dom->query('/root/*'));
     $this->assertInstanceOf('TheSeer\\fDOM\\fDOMDocumentFragment', $frag);
     $this->assertEquals(2, $frag->childNodes->length);
 }
コード例 #3
0
ファイル: GlobalConfig.php プロジェクト: beingsane/phpdox
 /**
  * @return array
  */
 public function getProjects()
 {
     $list = array();
     foreach ($this->cfg->query('//cfg:project[@enabled="true" or not(@enabled)]') as $pos => $project) {
         $list[$project->getAttribute('name', $pos)] = new ProjectConfig($this->runResolver($project));
     }
     return $list;
 }
コード例 #4
0
ファイル: GlobalConfig.php プロジェクト: sakshika/ATM
 public function getAvailableProjects()
 {
     $list = array();
     foreach ($this->cfg->query('//cfg:project[@enabled="true" or not(@enabled)]') as $pos => $project) {
         $list[] = $project->getAttribute('name') ?: $pos;
     }
     return $list;
 }
コード例 #5
0
 /**
  * @return string
  */
 public function renderStripped()
 {
     $dom = new fDOMDocument();
     $dom->preserveWhiteSpace = FALSE;
     $dom->loadXML(preg_replace("/\\s{2,}/u", " ", $this->render()));
     foreach ($dom->query('//comment()') as $c) {
         $c->parentNode->removeChild($c);
     }
     $dom->formatOutput = TRUE;
     return $dom->saveXML();
 }
コード例 #6
0
ファイル: CheckStyle.php プロジェクト: webkingashu/phpdox
 private function loadFindings($xmlFile)
 {
     $this->findings = array();
     try {
         if (!file_exists($xmlFile)) {
             throw new EnricherException(sprintf('Logfile "%s" not found.', $xmlFile), EnricherException::LoadError);
         }
         $dom = new fDOMDocument();
         $dom->load($xmlFile);
         foreach ($dom->query('/checkstyle/file') as $file) {
             $this->findings[$file->getAttribute('name')] = $file->query('*');
         }
     } catch (fDOMException $e) {
         throw new EnricherException('Parsing checkstyle logfile failed: ' . $e->getMessage(), EnricherException::LoadError);
     }
 }
コード例 #7
0
ファイル: AbstractUnitObject.php プロジェクト: theseer/phpdox
 private function hasMethod($name)
 {
     return $this->dom->query(sprintf('phpdox:method[@name="%s"]', $name))->length > 0;
 }
コード例 #8
0
ファイル: CLI.php プロジェクト: beingsane/phpdox
 private function showSkeletonConfig($strip)
 {
     $config = file_get_contents(__DIR__ . '/config/skeleton.xml');
     if ($strip) {
         $config = preg_replace("/\\s{2,}/u", " ", $config);
         $dom = new fDOMDocument();
         $dom->preserveWhiteSpace = FALSE;
         $dom->loadXML($config);
         foreach ($dom->query('//comment()') as $c) {
             $c->parentNode->removeChild($c);
         }
         $dom->formatOutput = TRUE;
         $config = $dom->saveXML();
     }
     echo $config;
 }
コード例 #9
0
ファイル: PHPUnit.php プロジェクト: webkingashu/phpdox
 private function processUnit(fDOMDocument $unit, fDOMDocument $coverage)
 {
     $enrichment = $this->getEnrichtmentContainer($unit->documentElement, 'phpunit');
     $className = $unit->documentElement->getAttribute('name');
     $classNamespace = $unit->documentElement->getAttribute('namespace');
     $classNode = $coverage->queryOne(sprintf('//pu:class[@name = "%s" and pu:namespace[@name = "%s"]]', $className, $classNamespace));
     if (!$classNode) {
         // This class seems to be newer than the last phpunit run
         return;
     }
     $coverageTarget = $enrichment->appendElementNS(self::XMLNS, 'coverage');
     foreach (array('executable', 'executed', 'crap') as $attr) {
         $coverageTarget->appendChild($coverageTarget->ownerDocument->importNode($classNode->getAttributeNode($attr)));
     }
     $result = array('PASSED' => 0, 'SKIPPED' => 0, 'INCOMPLETE' => 0, 'FAILURE' => 0, 'ERROR' => 0, 'RISKY' => 0);
     $methods = $unit->query('/phpdox:*/phpdox:constructor|/phpdox:*/phpdox:destructor|/phpdox:*/phpdox:method');
     $xp = $this->index->getDOMXPath();
     foreach ($methods as $method) {
         $start = $method->getAttribute('start');
         $end = $method->getAttribute('end');
         $enrichment = $this->getEnrichtmentContainer($method, 'phpunit');
         $coverageTarget = $enrichment->appendElementNS(self::XMLNS, 'coverage');
         /** @var fDOMElement $coverageMethod */
         $coverageMethod = $coverage->queryOne(sprintf('//pu:method[@start = "%d" and @end = "%d"]', $start, $end));
         if ($coverageMethod != NULL) {
             foreach (array('executable', 'executed', 'coverage', 'crap') as $attr) {
                 $coverageTarget->appendChild($coverageTarget->ownerDocument->importNode($coverageMethod->getAttributeNode($attr)));
             }
         }
         $coveredNodes = $coverage->query(sprintf('//pu:coverage/pu:line[@nr >= "%d" and @nr <= "%d"]/pu:covered', $start, $end));
         $seen = array();
         foreach ($coveredNodes as $coveredNode) {
             $by = $coveredNode->getAttribute('by');
             if (isset($seen[$by])) {
                 continue;
             }
             $seen[$by] = true;
             $name = $xp->prepare(':name', array('name' => $by));
             $test = $coverageTarget->appendChild($unit->importNode($this->index->queryOne(sprintf('//pu:tests/pu:test[@name = %s]', $name))));
             $result[$test->getAttribute('status')]++;
         }
     }
     if (!isset($this->results[$classNamespace])) {
         $this->results[$classNamespace] = array();
         $this->coverage[$classNamespace] = array();
     }
     $this->results[$classNamespace][$className] = $result;
     $this->coverage[$classNamespace][$className] = $coverageTarget->cloneNode(false);
 }
コード例 #10
0
 /**
  * @return MethodCollection
  */
 public function getMethods()
 {
     return new MethodCollection($this->dom->query('phpdox:constructor|phpdox:method|phpdox:destructor'));
 }
コード例 #11
0
ファイル: MetadataCollector.php プロジェクト: renanbr/phpact
 /**
  * @param string[] $units
  * @param string[] $visibilities
  * @return fDOMDocument
  */
 private function createPhpDoxConfig(array $units, array $visibilities)
 {
     $dom = new fDOMDocument();
     $dom->loadXML($this->factory->getConfigSkeleton()->renderStripped());
     $dom->registerNamespace('config', ConfigLoader::XMLNS);
     // set up silent
     $silent = $this->output->getVerbosity() <= OutputInterface::VERBOSITY_NORMAL ? 'true' : 'false';
     $dom->queryOne('//config:phpdox')->setAttribute('silent', $silent);
     // set up directories
     $projectNode = $dom->queryOne('//config:project');
     $projectNode->setAttribute('source', $this->sourceDirectory);
     $projectNode->setAttribute('workdir', $this->buildDirectory);
     // inject flag to avoid unecessary processing according to the visibility filter
     if (1 === count($visibilities) && in_array('public', $visibilities)) {
         $collectorNode = $dom->queryOne('//config:collector');
         $projectNode->setAttribute('publiconly', 'true');
     }
     // remove current masks
     $query = "//config:collector/*[name()='include' or name()='exclude']";
     foreach ($dom->query($query) as $mask) {
         $mask->parentNode->removeChild($mask);
     }
     // append files to be parsed
     $collector = $dom->queryOne('//config:collector');
     foreach ($units as $unitFile) {
         $include = $dom->createElement('include');
         $include->setAttribute('mask', $unitFile);
         $collector->appendChild($include);
     }
     return $dom;
 }
コード例 #12
0
ファイル: Project.php プロジェクト: sakshika/ATM
 /**
  * @param $fname
  *
  * @return array
  */
 private function findAffectedUnits($fname)
 {
     $affected = array();
     $dom = new fDOMDocument();
     $dom->load($this->xmlDir . '/' . $fname);
     $dom->registerNamespace('phpdox', 'http://xml.phpdox.net/src#');
     $extends = $dom->queryOne('//phpdox:extends');
     if ($extends instanceof fDOMElement) {
         try {
             $affected[$extends->getAttribute('full')] = $this->getUnitByName($extends->getAttribute('full'));
         } catch (ProjectException $e) {
         }
     }
     $implements = $dom->query('//phpdox:implements');
     foreach ($implements as $implement) {
         try {
             $affected[$implement->getAttribute('full')] = $this->getUnitByName($implement->getAttribute('full'));
         } catch (ProjectException $e) {
         }
     }
     return $affected;
 }
コード例 #13
0
ファイル: Project.php プロジェクト: mostwanted1976/phpdox
 /**
  * @param string $namespace
  * @return InterfaceCollection
  */
 public function getInterfaces($namespace = NULL)
 {
     $root = $namespace !== NULL ? sprintf('//phpdox:namespace[@name="%s"]/', $namespace) : '//';
     return new InterfaceCollection($this->index->query($root . 'phpdox:interface'));
 }
コード例 #14
0
ファイル: Project.php プロジェクト: renanbr/phpact
 /**
  * @return UnitCollection
  */
 public function getUnits()
 {
     $query = "//src:index/src:namespace/*[name()='class' or name()='interface' or name()='trait']";
     return new UnitCollection($this->index->query($query), $this->buildDirectory);
 }