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


PHP fDOMDocument::importNode方法代码示例

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


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

示例1: importExports

 /**
  * @param AbstractUnitObject $unit
  */
 public function importExports(AbstractUnitObject $unit, $container = 'parent')
 {
     $parent = $this->rootNode->queryOne(sprintf('//phpdox:%s[@full="%s"]', $container, $unit->getName()));
     if ($parent instanceof fDOMElement) {
         $parent->parentNode->removeChild($parent);
     }
     $parent = $this->rootNode->appendElementNS(self::XMLNS, $container);
     $parent->setAttribute('full', $unit->getName());
     $parent->setAttribute('namepsace', $unit->getNamespace());
     $parent->setAttribute('name', $unit->getLocalName());
     if ($unit->hasExtends()) {
         foreach ($unit->getExtends() as $name) {
             $extends = $parent->appendElementNS(self::XMLNS, 'extends');
             $this->setName($name, $extends);
         }
     }
     foreach ($unit->getConstants() as $constant) {
         $parent->appendChild($this->dom->importNode($constant->export(), TRUE));
     }
     foreach ($unit->getExportedMembers() as $member) {
         $parent->appendChild($this->dom->importNode($member->export(), TRUE));
     }
     foreach ($unit->getExportedMethods() as $method) {
         $parent->appendChild($this->dom->importNode($method->export(), TRUE));
     }
 }
开发者ID:sakshika,项目名称:ATM,代码行数:29,代码来源:AbstractUnitObject.php

示例2: processFinding

 protected function processFinding(fDOMDocument $dom, $ref, \DOMElement $finding)
 {
     $enrichment = $this->getEnrichtmentContainer($ref, 'checkstyle');
     $enrichFinding = $dom->createElementNS(self::XMLNS, $finding->tagName);
     $enrichment->appendChild($enrichFinding);
     foreach ($finding->attributes as $attr) {
         if ($attr->localName == 'severity') {
             continue;
         }
         $enrichFinding->setAttributeNode($dom->importNode($attr, true));
     }
     $enrichFinding->setAttribute('message', $finding->nodeValue);
 }
开发者ID:mostwanted1976,项目名称:phpdox,代码行数:13,代码来源:PHPCs.php

示例3: importTraitExports

 public function importTraitExports(AbstractUnitObject $trait, TraitUseObject $use)
 {
     $container = $this->rootNode->queryOne(sprintf('phpdox:trait[@full="%s"]', $trait->getName()));
     if ($container instanceof fDOMElement) {
         $container->parentNode->removeChild($container);
     }
     $container = $this->rootNode->appendElementNS(self::XMLNS, 'trait');
     $this->setName($trait->getName(), $container);
     if ($trait->hasExtends()) {
         foreach ($trait->getExtends() as $name) {
             $extends = $container->appendElementNS(self::XMLNS, 'extends');
             $this->setName($name, $extends);
         }
     }
     if ($trait->usesTraits()) {
         foreach ($trait->getUsedTraits() as $name) {
             $used = $container->appendElementNS(self::XMLNS, 'uses');
             $this->setName($name, $used);
         }
     }
     foreach ($trait->getConstants() as $constant) {
         $container->appendChild($this->dom->importNode($constant->export(), TRUE));
     }
     foreach ($trait->getExportedMembers() as $member) {
         $memberNode = $this->dom->importNode($member->export(), TRUE);
         $this->adjustStaticResolution($memberNode);
         $container->appendChild($memberNode);
     }
     foreach ($trait->getExportedMethods() as $method) {
         $methodName = $method->getName();
         $methodNode = $this->dom->importNode($method->export(), TRUE);
         if (!$use->isExcluded($methodName)) {
             $container->appendChild($methodNode);
         }
         $this->adjustStaticResolution($methodNode);
         $aliasNode = NULL;
         if ($use->isAliased($methodName)) {
             $aliasNode = $methodNode->cloneNode(true);
             $aliasNode->setAttribute('original', $aliasNode->getAttribute('name'));
             $aliasNode->setAttribute('name', $use->getAliasedName($methodName));
             if ($use->hasAliasedModifier($methodName)) {
                 $aliasNode->setAttribute('visibility', $use->getAliasedModifier($methodName));
             }
             $container->appendChild($aliasNode);
         }
     }
 }
开发者ID:theseer,项目名称:phpdox,代码行数:47,代码来源:AbstractUnitObject.php

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

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

示例6: genericProcess

 private function genericProcess(fDOMDocument $dom)
 {
     $enrichment = $this->getEnrichtmentContainer($dom->documentElement, 'build');
     $enrichment->appendChild($dom->importNode($this->getGeneralBuildInfo(), true));
 }
开发者ID:mostwanted1976,项目名称:phpdox,代码行数:5,代码来源:Build.php

示例7: asDom

 public function asDom(fDOMDocument $dom)
 {
     return $dom->importNode($this->fragment, true);
 }
开发者ID:webkingashu,项目名称:phpdox,代码行数:4,代码来源:InlineComment.php

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

示例9: mergeFiles

 /**
  * Merge all files.
  *
  * @param string $directory
  * @param Finder $finder
  *
  * @return fDOMDocument
  */
 private function mergeFiles($directory, Finder $finder)
 {
     $outXml = new fDOMDocument();
     $outXml->formatOutput = true;
     $outTestSuites = $outXml->createElement('testsuites');
     $outXml->appendChild($outTestSuites);
     $outTestSuite = $outXml->createElement('testsuite');
     $outTestSuites->appendChild($outTestSuite);
     $tests = 0;
     $assertions = 0;
     $failures = 0;
     $errors = 0;
     $time = 0;
     /** @var SplFileInfo $file */
     foreach ($finder as $file) {
         if ($this->isFileEmpty($file)) {
             continue;
         }
         $inXml = $this->loadFile($file->getRealpath());
         foreach ($inXml->query('//testsuites/testsuite') as $inElement) {
             $inName = $inElement->getAttribute('name');
             $outName = $inName;
             $suffix = 2;
             while ($outTestSuite->query('//testsuite[@name="' . $outName . '"]')->length !== 0) {
                 $outName = $inName . '_' . $suffix;
                 $suffix++;
             }
             $outElement = $outXml->importNode($inElement, true);
             $outElement->setAttribute('name', $outName);
             $outTestSuite->appendChild($outElement);
             $tests += $inElement->getAttribute('tests');
             $assertions += $inElement->getAttribute('assertions');
             $failures += $inElement->getAttribute('failures');
             $errors += $inElement->getAttribute('errors');
             $time += $inElement->getAttribute('time');
         }
     }
     $outTestSuite->setAttribute('name', $directory);
     $outTestSuite->setAttribute('tests', $tests);
     $outTestSuite->setAttribute('assertions', $assertions);
     $outTestSuite->setAttribute('failures', $failures);
     $outTestSuite->setAttribute('errors', $errors);
     $outTestSuite->setAttribute('time', $time);
     return $outXml;
 }
开发者ID:andreas-weber,项目名称:php-junit-merge,代码行数:53,代码来源:Command.php


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