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);
 }
Example #2
0
 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);
     }
 }
Example #3
0
 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;
 }
Example #4
0
 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;
 }
Example #5
0
 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;
 }
Example #6
0
 /**
  * @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'));
 }
Example #8
0
 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;
 }
Example #10
0
 /**
  * @ 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);
 }
Example #11
0
 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);
     }
 }
Example #12
0
 /**
  * @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);
 }
Example #13
0
 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);
     }
 }
Example #14
0
 /**
  * @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);
 }
Example #15
0
 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);
     }
 }
Example #16
0
 /**
  * @param fDOMElement $element
  * @return Unit
  */
 protected function buildObject(fDOMElement $element)
 {
     $document = new fDOMDocument();
     $document->load($this->buildDirectory . '/' . $element->getAttribute('xml'));
     return new Unit($document);
 }
Example #17
0
 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);
 }
Example #20
0
 /**
  * @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);
     }
 }
Example #21
0
 /**
  * @param string $file
  * @return Project
  */
 protected static function getProject($file)
 {
     $index = new fDOMDocument();
     $index->load($file);
     return new Project($index, dirname($file));
 }
Example #22
0
 /**
  * @param SpecificationFilename $file
  */
 public function __construct($file)
 {
     $this->dom = new fDOMDocument();
     $this->dom->load($file);
 }
Example #23
0
 /**
  * Load an xml junit file.
  *
  * @param string $filename
  *
  * @return fDOMDocument
  */
 private function loadFile($filename)
 {
     $dom = new fDOMDocument();
     $dom->load($filename);
     return $dom;
 }
Example #24
0
 /**
  * @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);
     }
 }
Example #25
0
 /**
  * @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);
     }
 }