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


PHP fDOM\fDOMDocument类代码示例

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


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

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

示例2: generate

 public function generate()
 {
     $document = new fDOMDocument();
     // summary
     $root = $document->createElement('phpact');
     $root->setAttribute('project', $this->summary->getProjectName());
     $root->setAttribute('base', $this->summary->getBaseVersion());
     $root->setAttribute('challenger', $this->summary->getChallengerVersion());
     $root->setAttribute('date', date('c', $this->summary->getTime()));
     $root->setAttribute('signature', strip_tags($this->summary->getSignature()));
     // difference list
     $grouped = $this->groupDifferences($this->differences, Difference::UNIT_NAME);
     foreach ($grouped as $unitName => $differences) {
         /* @var $differences \RenanBr\PhpAct\Difference\DifferenceCollection */
         $family = $differences->current()->getTag(Difference::UNIT_FAMILY);
         $unitElement = $root->createElement($family);
         $unitElement->setAttribute('name', $unitName);
         $this->append($unitElement, 'constant', $differences, Difference::CONSTANT_NAME);
         $this->append($unitElement, 'member', $differences, Difference::MEMBER_NAME);
         $this->append($unitElement, 'method', $differences, Difference::METHOD_NAME);
         $root->appendChild($unitElement);
     }
     $document->appendChild($root);
     $document->preserveWhiteSpace = false;
     $document->formatOutput = true;
     return $document->saveXML();
 }
开发者ID:renanbr,项目名称:phpact,代码行数:27,代码来源:XmlReport.php

示例3: getUnitByName

 public function getUnitByName($name)
 {
     $parts = explode('\\', $name);
     $local = array_pop($parts);
     $namespace = join('\\', $parts);
     $indexNode = $this->index->queryOne(sprintf('//phpdox:namespace[@name="%s"]/*[@name="%s"]', $namespace, $local));
     if (!$indexNode) {
         throw new DependencyException(sprintf("Unit '%s' not found", $name), DependencyException::UnitNotFound);
     }
     $dom = new fDOMDocument();
     $dom->load($this->baseDir . '/' . $indexNode->getAttribute('xml'));
     switch ($indexNode->localName) {
         case 'interface':
             $unit = new InterfaceObject();
             $unit->import($dom);
             $this->project->addInterface($unit);
             break;
         case 'trait':
             $unit = new TraitObject();
             $unit->import($dom);
             $this->project->addTrait($unit);
             break;
         case 'class':
             $unit = new ClassObject();
             $unit->import($dom);
             $this->project->addClass($unit);
             break;
         default:
             throw new DependencyException(sprintf("Invalid unit type '%s'", $indexNode->localName), DependencyException::InvalidUnitType);
     }
     return $unit;
 }
开发者ID:mostwanted1976,项目名称:phpdox,代码行数:32,代码来源:Dependency.php

示例4: getUnitByName

 public function getUnitByName($name)
 {
     $parts = explode('\\', $name);
     $local = array_pop($parts);
     $namespace = join('\\', $parts);
     $indexNode = $this->index->queryOne(sprintf('//phpdox:namespace[@name="%s"]/*[@name="%s"]', $namespace, $local));
     if (!$indexNode) {
         return;
     }
     $dom = new fDOMDocument();
     $dom->load($this->baseDir . '/' . $indexNode->getAttribute('xml'));
     switch ($indexNode->localName) {
         case 'interface':
             $unit = new InterfaceObject();
             $unit->import($dom);
             $this->project->addInterface($unit);
             break;
         case 'trait':
             $unit = new TraitObject();
             $unit->import($dom);
             $this->project->addTrait($unit);
             break;
         case 'class':
             $unit = new ClassObject();
             $unit->import($dom);
             $this->project->addClass($unit);
             break;
     }
     return $unit;
 }
开发者ID:sakshika,项目名称:ATM,代码行数:30,代码来源:Dependency.php

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

示例6: init

 private function init($cfgName)
 {
     $this->version = new Version('0.0');
     $this->fileInfo = new FileInfo($this->baseDir . $cfgName . '.xml');
     $this->cfgDom = new fDOMDocument();
     $this->cfgDom->load($this->fileInfo->getPathname());
     $this->cfgDom->registerNamespace('cfg', 'http://xml.phpdox.net/config');
     $this->config = new GlobalConfig($this->version, new FileInfo('/tmp'), $this->cfgDom, $this->fileInfo);
 }
开发者ID:mostwanted1976,项目名称:phpdox,代码行数:9,代码来源:GlobalConfigTest.php

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

示例8: loadDocument

 protected function loadDocument($dir)
 {
     $path = $dir . '/' . $this->getNode()->getAttribute('xml');
     if (!isset($this->dom[$path])) {
         $classDom = new fDOMDocument();
         $classDom->load($path);
         $classDom->registerNamespace('phpdox', 'http://xml.phpdox.net/src');
         $this->dom[$path] = $classDom;
     }
     return $this->dom[$path];
 }
开发者ID:mostwanted1976,项目名称:phpdox,代码行数:11,代码来源:AbstractEntry.php

示例9: asDom

 public function asDom(\TheSeer\fDOM\fDOMDocument $ctx)
 {
     $node = $ctx->createElementNS('http://xml.phpdox.net/src', 'invalid');
     $node->setAttribute('annotation', $this->name);
     foreach ($this->attributes as $attribute => $value) {
         $node->setAttribute($attribute, $value);
     }
     if ($this->body !== null && $this->body !== '') {
         $node->appendChild($ctx->createTextnode($this->body));
     }
     return $node;
 }
开发者ID:theseer,项目名称:phpdox,代码行数:12,代码来源:InvalidElement.php

示例10: loadXML

 private function loadXML($fname)
 {
     try {
         if (!file_exists($fname)) {
             throw new EnricherException(sprintf('PHPLoc xml file "%s" not found.', $fname), EnricherException::LoadError);
         }
         $this->dom = new fDOMDocument();
         $this->dom->load($fname);
     } catch (fDOMException $e) {
         throw new EnricherException('Parsing PHPLoc xml file failed: ' . $e->getMessage(), EnricherException::LoadError);
     }
 }
开发者ID:sakshika,项目名称:ATM,代码行数:12,代码来源:PHPLoc.php

示例11: processFinding

 protected function processFinding(fDOMDocument $dom, $ref, \DOMElement $finding)
 {
     $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:webkingashu,项目名称:phpdox,代码行数:12,代码来源:CheckStyle.php

示例12: asDom

 public function asDom(\TheSeer\fDOM\fDOMDocument $ctx)
 {
     $node = $ctx->createElementNS('http://xml.phpdox.net/src#', strtolower($this->name));
     foreach ($this->attributes as $attribute => $value) {
         $node->setAttribute($attribute, $value);
     }
     if ($this->body !== null && $this->body !== '') {
         $parser = $this->factory->getInstanceFor('InlineProcessor', $ctx);
         $node->appendChild($parser->transformToDom($this->body));
     }
     return $node;
 }
开发者ID:sakshika,项目名称:ATM,代码行数:12,代码来源:GenericElement.php

示例13: testParse

 /**
  * @ covers TheSeer\phpDox\DocBlock\Parser::__construct
  * @ covers TheSeer\phpDox\DocBlock\Parser::parse
  *
  * @dataProvider docblockSources
  */
 public function testParse($src)
 {
     $expected = new fDOMDocument();
     $dir = __DIR__ . '/../../data/docbock/';
     $block = file_get_contents($dir . $src);
     $expected->load($dir . $src . '.xml');
     $factory = new Factory();
     $parser = new Parser($factory);
     $result = $parser->parse($block, array());
     $this->assertInstanceOf('TheSeer\\phpDox\\DocBlock\\DocBlock', $result);
     $dom = new fDOMDocument();
     $dom->appendChild($result->asDom($dom));
     $this->assertEquals($expected->documentElement, $dom->documentElement);
 }
开发者ID:gandazgul,项目名称:phpdox,代码行数:20,代码来源:parserTest.php

示例14: asDom

 /**
  * @param \TheSeer\fDOM\fDOMDocument $doc
  * @return \TheSeer\fDOM\fDOMElement
  */
 public function asDom(\TheSeer\fDOM\fDOMDocument $doc)
 {
     $node = $doc->createElementNS('http://xml.phpdox.net/src#', 'docblock');
     // add lines and such?
     foreach ($this->elements as $element) {
         if (is_array($element)) {
             foreach ($element as $el) {
                 $node->appendChild($el->asDom($doc));
             }
             continue;
         }
         $node->appendChild($element->asDom($doc));
     }
     return $node;
 }
开发者ID:sakshika,项目名称:ATM,代码行数:19,代码来源:DocBlock.php

示例15: testQueryReturnsNodeFromClonedDocument

 /**
  * https://github.com/theseer/fDOMDocument/issues/15
  */
 public function testQueryReturnsNodeFromClonedDocument()
 {
     $this->dom->loadXML('<?xml version="1.0" ?><test />');
     $clone = clone $this->dom;
     $node = $clone->queryOne('/test');
     $this->assertNotSame($this->dom->documentElement, $node);
 }
开发者ID:KingNoosh,项目名称:Teknik,代码行数:10,代码来源:fDOMDocument.test.php


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