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); }
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); } }
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; }
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; }
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; }
/** * @return void */ private function initCollections() { $this->source = new fDOMDocument(); $this->source->load($this->xmlDir . '/source.xml'); $this->source->registerNamespace('phpdox', 'http://xml.phpdox.net/src'); $this->index = new fDOMDocument(); $this->index->load($this->xmlDir . '/index.xml'); $this->index->registerNamespace('phpdox', 'http://xml.phpdox.net/src'); }
public function testCSSSelectorHonorsContextNode() { $this->dom->load(__DIR__ . '/_data/selector.xml'); $ctx = $this->dom->getElementsByTagName('child')->item(0); $result = $this->dom->select('child', $ctx); $this->assertEquals(1, $result->length); $this->assertEquals('child', $result->item(0)->nodeName); $this->assertEquals('other', $result->item(0)->getAttribute('attr')); }
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]; }
/** * @param string $filename * * @return Configuration */ public function load($filename) { $document = new fDOMDocument(); $document->load($filename); $configuration = new Configuration($document->getElementsByTagName('directory')->item(0)->textContent, $document->getElementsByTagName('domain')->item(0)->textContent, $document->getElementsByTagName('email')->item(0)->textContent); if ($document->getElementsByTagName('nginx')->item(0)) { $configuration->setNginxConfigurationFile($document->getElementsByTagName('nginx')->item(0)->textContent); } foreach ($document->getElementsByTagName('series') as $series) { /* @var fDOMElement $series */ $configuration->addAdditionalReleaseSeries($series->getAttribute('package'), $series->getAttribute('series'), $series->getAttribute('alias')); } return $configuration; }
/** * @ 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); }
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); } }
/** * @param string[] $units * @param string[] $visibilities * @return Project */ public function collect(array $units, array $visibilities) { $this->factory = $this->factory ?: $this->createPhpDoxFactory(); // set up build directory if (!is_dir($this->buildDirectory)) { mkdir($this->buildDirectory, 0755, true); } // create phpdox.xml config file $configFile = $this->buildDirectory . '/phpdox.xml'; $config = $this->createPhpDoxConfig($units, $visibilities); file_put_contents($configFile, $config->saveXML()); // do collect $this->runPhpDoxCollector($configFile); $phpDoxIndex = new fDOMDocument(); $phpDoxIndex->load($this->buildDirectory . '/index.xml'); return new Project($phpDoxIndex, $this->buildDirectory); }
protected function createInstanceFor($fname) { try { $dom = new fDOMDocument(); $dom->load($fname); $root = $dom->documentElement; if ($root->namespaceURI == 'http://phpdox.de/config') { throw new ConfigLoaderException("File '{$fname}' uses an outdated xml namespace. Please update the xmlns to 'http://phpdox.net/config'", ConfigLoaderException::OldNamespace); } if ($root->namespaceURI != 'http://phpdox.net/config' || $root->localName != 'phpdox') { throw new ConfigLoaderException("File '{$fname}' is not a valid phpDox configuration.", ConfigLoaderException::WrongType); } $dom->registerNamespace('cfg', 'http://phpdox.net/config'); return new GlobalConfig($dom, new FileInfo($fname)); } catch (fDOMException $e) { throw new ConfigLoaderException("Parsing config file '{$fname}' failed.", ConfigLoaderException::ParseError, $e); } }
/** * @covers \TheSeer\fDOM\fDOMDocument::queryOne */ public function testQueryOneReturnsElement() { $this->dom->load(__DIR__ . '/_data/valid.xml'); $node = $this->dom->queryOne('/test'); $this->assertInstanceOf('TheSeer\\fDOM\\fDOMElement', $node); }
private function setupDependencies() { $this->dependencyStack = array($this->project); foreach ($this->config->getDependencyDirectories() as $depDir) { $idxName = $depDir . '/index.xml'; if (!file_exists($idxName)) { $this->logger->log("'{$idxName}' not found - skipping dependency"); continue; } $dom = new fDOMDocument(); $dom->load($idxName); $this->dependencyStack[] = new Dependency($dom, $this->project); } }
/** * @param fDOMElement $element * @return Unit */ protected function buildObject(fDOMElement $element) { $document = new fDOMDocument(); $document->load($this->buildDirectory . '/' . $element->getAttribute('xml')); return new Unit($document); }
protected function loadDataFile($filename) { $classDom = new fDOMDocument(); $classDom->load($this->xmlDir . '/' . $filename); $classDom->registerNamespace('phpdox', 'http://xml.phpdox.net/src#'); return $classDom; }
/** * @param SpecificationFilename $file */ public function __construct(SpecificationFilename $file) { $this->dom = new fDOMDocument(); $this->dom->load($file); }
/** * @param string $file */ public function __construct($file) { $this->basePath = dirname($file); $this->xml = new fDOMDocument(); $this->xml->load($file); }
/** * @param $fname * * @return fDOMDocument * * @throws EnricherException */ private function loadXML($fname) { try { $fname = (string) $this->coveragePath . '/' . $fname; if (!file_exists($fname)) { throw new EnricherException(sprintf('PHPUnit xml file "%s" not found.', $fname), EnricherException::LoadError); } $dom = new fDOMDocument(); $dom->load($fname); $dom->registerNamespace('pu', 'http://schema.phpunit.de/coverage/1.0'); return $dom; } catch (fDOMException $e) { throw new EnricherException('Parsing PHPUnit xml file failed: ' . $e->getMessage(), EnricherException::LoadError); } }
/** * @param string $file * @return Project */ protected static function getProject($file) { $index = new fDOMDocument(); $index->load($file); return new Project($index, dirname($file)); }
/** * @param SpecificationFilename $file */ public function __construct($file) { $this->dom = new fDOMDocument(); $this->dom->load($file); }
/** * Load an xml junit file. * * @param string $filename * * @return fDOMDocument */ private function loadFile($filename) { $dom = new fDOMDocument(); $dom->load($filename); return $dom; }
/** * @return void */ private function initCollections() { $this->source = new SourceCollection($this->srcDir); $srcFile = $this->xmlDir . '/source.xml'; if (file_exists($srcFile)) { $dom = new fDOMDocument(); $dom->load($srcFile); $this->source->import($dom); } $this->index = new IndexCollection(); $srcFile = $this->xmlDir . '/index.xml'; if (file_exists($srcFile)) { $dom = new fDOMDocument(); $dom->load($srcFile); $this->index->import($dom); } }
/** * @param $fname * * @return fDOMDocument * @throws ConfigLoaderException */ private function loadFile($fname) { try { $dom = new fDOMDocument(); $dom->load($fname); $dom->registerNamespace('cfg', self::XMLNS); return $dom; } catch (fDOMException $e) { throw new ConfigLoaderException("Parsing config file '{$fname}' failed.", ConfigLoaderException::ParseError, $e); } }