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


PHP fDOMDocument::queryOne方法代码示例

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


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

示例1: isSilentMode

 /**
  * @return bool
  */
 public function isSilentMode()
 {
     $root = $this->cfg->queryOne('/cfg:phpdox');
     if (!$root instanceof \DomNode) {
         return false;
     }
     return $root->getAttribute('silent', 'false') === 'true';
 }
开发者ID:beingsane,项目名称:phpdox,代码行数:11,代码来源:GlobalConfig.php

示例2: getCacheDom

 private function getCacheDom()
 {
     if ($this->cacheDom === NULL) {
         $this->cacheDom = new fDOMDocument();
         $cacheFile = $this->config->getLogfilePath();
         if (file_exists($cacheFile)) {
             $this->cacheDom->load($cacheFile);
             $sha1 = $this->cacheDom->documentElement->getAttribute('sha1');
             $cwd = getcwd();
             chdir($this->config->getSourceDirectory());
             exec($this->config->getGitBinary() . ' diff --name-only ' . $sha1, $files, $rc);
             foreach ($files as $file) {
                 $fields = array('path' => dirname($file), 'file' => basename($file));
                 $query = $this->cacheDom->prepareQuery('//*[@path = :path and @file = :file]', $fields);
                 $node = $this->cacheDom->queryOne($query);
                 if (!$node) {
                     continue;
                 }
                 $node->parentNode->removeChild($node);
             }
             chdir($cwd);
         } else {
             $this->cacheDom->loadXML('<?xml version="1.0" ?><gitlog xmlns="' . self::GITNS . '" />');
             $this->cacheDom->documentElement->setAttribute('sha1', $this->commitSha1);
         }
     }
     return $this->cacheDom;
 }
开发者ID:beingsane,项目名称:phpdox,代码行数:28,代码来源:Git.php

示例3: import

 public function import(fDOMDocument $dom) {
     $dom->registerNamespace('phpdox', 'http://xml.phpdox.net/src#');
     $dir = $dom->queryOne('/phpdox:source/phpdox:dir');
     if (!$dir)  {
         return;
     }
     $this->importDirNode($dir, '');
 }
开发者ID:rxz135cc,项目名称:yii2webApp,代码行数:8,代码来源:SourceCollection.php

示例4: getMethod

 private function getMethod($name)
 {
     $ctx = $this->dom->queryOne(sprintf('phpdox:method[@name="%s"]', $name));
     if (!$ctx) {
         throw new UnitObjectException(sprintf('Method "%s" not found', $name), UnitObjectException::NoSuchMethod);
     }
     return new MethodObject($this, $ctx);
 }
开发者ID:theseer,项目名称:phpdox,代码行数:8,代码来源:AbstractUnitObject.php

示例5: getProjectConfig

 public function getProjectConfig($project)
 {
     $filter = is_int($project) ? $project : "@name = '{$project}'";
     $ctx = $this->cfg->queryOne("//cfg:project[{$filter}]");
     if (!$ctx) {
         throw new ConfigException("Project '{$project}' not found in configuration xml file", ConfigException::ProjectNotFound);
     }
     return new ProjectConfig($this->runResolver($ctx));
 }
开发者ID:sakshika,项目名称:ATM,代码行数:9,代码来源:GlobalConfig.php

示例6: processFindings

 private function processFindings(fDOMDocument $dom, \DOMNodeList $findings)
 {
     foreach ($findings as $finding) {
         /** @var fDOMElement $finding */
         $line = $finding->getAttribute('line');
         $ref = $dom->queryOne(sprintf('//phpdox:*/*[@line = %d or (@start <= %d and @end >= %d)]', $line, $line, $line));
         if (!$ref) {
             // One src file may contain multiple classes/traits/interfaces, so the
             // finding might not apply to the current object since findings are based on filenames
             // but we have individual objects - so we just ignore the finding for this context
             continue;
         }
         $this->processFinding($dom, $ref, $finding);
     }
 }
开发者ID:webkingashu,项目名称:phpdox,代码行数:15,代码来源:CheckStyle.php

示例7: processViolations

 private function processViolations(fDOMDocument $dom, \DOMNodeList $violations)
 {
     foreach ($violations as $violation) {
         /** @var fDOMElement $violation */
         $line = $violation->getAttribute('beginline');
         $ref = $dom->queryOne(sprintf('//phpdox:*/*[@line = %d or (@start <= %d and @end >= %d)]', $line, $line, $line));
         if (!$ref) {
             // One src file may contain multiple classes/traits/interfaces, so the
             // finding might not apply to the current object since violations are based on filenames
             // but we have individual objects - so we just ignore the finding for this context
             continue;
         }
         $enrichment = $this->getEnrichtmentContainer($ref, 'pmd');
         $enrichViolation = $dom->createElementNS(self::XMLNS, 'violation');
         $enrichment->appendChild($enrichViolation);
         $enrichViolation->setAttribute('message', trim($violation->nodeValue));
         foreach ($violation->attributes as $attr) {
             $enrichViolation->setAttributeNode($dom->importNode($attr, true));
         }
     }
 }
开发者ID:mostwanted1976,项目名称:phpdox,代码行数:21,代码来源:PHPMessDetector.php

示例8: processFindings

 private function processFindings(fDOMDocument $dom, \DOMNodeList $findings)
 {
     foreach ($findings as $finding) {
         /** @var fDOMElement $finding */
         $line = $finding->getAttribute('line');
         $ref = $dom->queryOne(sprintf('//phpdox:*/*[@line = %d or (@start <= %d and @end >= %d)]', $line, $line, $line));
         if (!$ref) {
             // One src file may contain multiple classes/traits/interfaces, so the
             // finding might not apply to the current object since findings are based on filenames
             // but we have individual objects - so we just ignore the finding for this context
             continue;
         }
         $enrichment = $this->getEnrichtmentContainer($ref, 'checkstyle');
         $enrichFinding = $dom->createElementNS(self::XMLNS, $finding->getAttribute('severity', 'error'));
         $enrichment->appendChild($enrichFinding);
         foreach ($finding->attributes as $attr) {
             if ($attr->localName == 'severity') {
                 continue;
             }
             $enrichFinding->setAttributeNode($dom->importNode($attr, true));
         }
     }
 }
开发者ID:sakshika,项目名称:ATM,代码行数:23,代码来源:CheckStyle.php

示例9: getInterfaceClassName

 /**
  * @return string
  */
 public function getInterfaceClassName()
 {
     return $this->dom->queryOne('configuration/interface')->getAttribute('name');
 }
开发者ID:anis-marrouchi,项目名称:state,代码行数:7,代码来源:SpecificationParser.php

示例10: loadCoverageInformation

 /**
  * @param fDOMDocument $dom
  *
  * @return fDOMDocument
  *
  * @throws EnricherException
  * @throws PHPUnitEnricherException
  */
 private function loadCoverageInformation(fDOMDocument $dom)
 {
     $fileNode = $dom->queryOne('//phpdox:file');
     if (!$fileNode) {
         throw new PHPUnitEnricherException('No file header in event dom');
     }
     $fileInfo = new FileInfo($fileNode->getAttribute('path'));
     $srcDir = $this->getSourceDirectory();
     $paths = explode('/', (string) $fileInfo->getRelative($srcDir));
     $file = $fileNode->getAttribute('file');
     $paths = array_slice($paths, 1);
     $query = sprintf('//pu:project/pu:directory[@name = "%s"]', $srcDir->getRealPath());
     foreach ($paths as $path) {
         $query .= sprintf('/pu:directory[@name = "%s"]', $path);
     }
     $query .= sprintf('/pu:file[@name = "%s"]', $file);
     $phpunitFileNode = $this->index->queryOne($query);
     if (!$phpunitFileNode) {
         throw new PHPUnitEnricherException('No coverage information for file');
     }
     $refDom = $this->loadXML($phpunitFileNode->getAttribute('href'));
     return $refDom;
 }
开发者ID:webkingashu,项目名称:phpdox,代码行数:31,代码来源:PHPUnit.php

示例11: isSilentMode

 /**
  * @return bool
  */
 public function isSilentMode()
 {
     $root = $this->cfg->queryOne('/cfg:phpdox');
     return $root->getAttribute('silent', 'false') === 'true';
 }
开发者ID:theseer,项目名称:phpdox,代码行数:8,代码来源:GlobalConfig.php

示例12: 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

示例13: 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

示例14: 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:rxz135cc,项目名称:yii2webApp,代码行数:86,代码来源:PHPUnit.php

示例15: testThatTwoNodesAreIdentifiedAsBeingInTheSameDocument

 /**
  * @covers \TheSeer\fDOM\fDOMDocument::queryOne
  */
 public function testThatTwoNodesAreIdentifiedAsBeingInTheSameDocument()
 {
     $this->dom->loadXML('<?xml version="1.0" ?><root><node /></root>');
     $node = $this->dom->queryOne('//node');
     $this->assertTrue($this->dom->inSameDocument($node));
 }
开发者ID:KingNoosh,项目名称:Teknik,代码行数:9,代码来源:fDOMDocument.test.php


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