当前位置: 首页>>代码示例>>PHP>>正文


PHP fDOMDocument::query方法代码示例

本文整理汇总了PHP中TheSeer\fDOM\fDOMDocument::query方法的典型用法代码示例。如果您正苦于以下问题:PHP fDOMDocument::query方法的具体用法?PHP fDOMDocument::query怎么用?PHP fDOMDocument::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TheSeer\fDOM\fDOMDocument的用法示例。


在下文中一共展示了fDOMDocument::query方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: parse

 /**
  * @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);
 }
开发者ID:anis-marrouchi,项目名称:state,代码行数:29,代码来源:SpecificationParser.php

示例2: testTransformNodeListToFragmentWorks

 /**
  * @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);
 }
开发者ID:KingNoosh,项目名称:Teknik,代码行数:10,代码来源:fDOMDocument.test.php

示例3: getProjects

 /**
  * @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;
 }
开发者ID:beingsane,项目名称:phpdox,代码行数:11,代码来源:GlobalConfig.php

示例4: getAvailableProjects

 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;
 }
开发者ID:sakshika,项目名称:ATM,代码行数:8,代码来源:GlobalConfig.php

示例5: renderStripped

 /**
  * @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();
 }
开发者ID:mostwanted1976,项目名称:phpdox,代码行数:14,代码来源:ConfigSkeleton.php

示例6: loadFindings

 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);
     }
 }
开发者ID:webkingashu,项目名称:phpdox,代码行数:16,代码来源:CheckStyle.php

示例7: hasMethod

 private function hasMethod($name)
 {
     return $this->dom->query(sprintf('phpdox:method[@name="%s"]', $name))->length > 0;
 }
开发者ID:theseer,项目名称:phpdox,代码行数:4,代码来源:AbstractUnitObject.php

示例8: showSkeletonConfig

 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;
 }
开发者ID:beingsane,项目名称:phpdox,代码行数:16,代码来源:CLI.php

示例9: processUnit

 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);
 }
开发者ID:webkingashu,项目名称:phpdox,代码行数:49,代码来源:PHPUnit.php

示例10: getMethods

 /**
  * @return MethodCollection
  */
 public function getMethods()
 {
     return new MethodCollection($this->dom->query('phpdox:constructor|phpdox:method|phpdox:destructor'));
 }
开发者ID:webkingashu,项目名称:phpdox,代码行数:7,代码来源:AbstractUnitObject.php

示例11: createPhpDoxConfig

 /**
  * @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;
 }
开发者ID:renanbr,项目名称:phpact,代码行数:36,代码来源:MetadataCollector.php

示例12: findAffectedUnits

 /**
  * @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;
 }
开发者ID:sakshika,项目名称:ATM,代码行数:27,代码来源:Project.php

示例13: getInterfaces

 /**
  * @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'));
 }
开发者ID:mostwanted1976,项目名称:phpdox,代码行数:9,代码来源:Project.php

示例14: getUnits

 /**
  * @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);
 }
开发者ID:renanbr,项目名称:phpact,代码行数:8,代码来源:Project.php


注:本文中的TheSeer\fDOM\fDOMDocument::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。