/** * Helper to output version information. */ private function showVersion() { static $shown = FALSE; if ($shown) { return; } $shown = TRUE; echo $this->version->getInfoString() . "\n\n"; }
private function getGeneralBuildInfo() { if ($this->buildInfo != NULL) { return $this->buildInfo; } $dom = new fDOMDocument(); $this->buildInfo = $dom->createDocumentFragment(); $dateNode = $dom->createElementNS(self::XMLNS, 'date'); $this->buildInfo->appendChild($dateNode); $date = new \DateTime('now'); $dateNode->setAttribute('unix', $date->getTimestamp()); $dateNode->setAttribute('date', $date->format('d-m-Y')); $dateNode->setAttribute('time', $date->format('H:i:s')); $dateNode->setAttribute('iso', $date->format('c')); $dateNode->setAttribute('rfc', $date->format('r')); $phpdoxNode = $dom->createElementNS(self::XMLNS, 'phpdox'); $this->buildInfo->appendChild($phpdoxNode); $phpdoxNode->setAttribute('version', $this->version->getVersion()); $phpdoxNode->setAttribute('info', $this->version->getInfoString()); $phpdoxNode->setAttribute('generated', $this->version->getGeneratedByString()); $phpdoxNode->setAttribute('phar', defined('PHPDOX_PHAR') ? 'yes' : 'no'); foreach ($this->enrichers as $enricher) { $enricherNode = $phpdoxNode->appendElementNS(self::XMLNS, 'enricher'); $enricherNode->setAttribute('type', $enricher); } $phpNode = $dom->createElementNS(self::XMLNS, 'php'); $this->buildInfo->appendChild($phpNode); $phpNode->setAttribute('version', PHP_VERSION); $phpNode->setAttribute('os', PHP_OS); foreach (get_loaded_extensions(true) as $extension) { $extNode = $dom->createElementNS(self::XMLNS, 'zendextension'); $extNode->setAttribute('name', $extension); $phpNode->appendChild($extNode); } foreach (get_loaded_extensions(false) as $extension) { $extNode = $dom->createElementNS(self::XMLNS, 'extension'); $extNode->setAttribute('name', $extension); $phpNode->appendChild($extNode); } return $this->buildInfo; }
/** * @param $ctx * * @return mixed * @throws ConfigException */ private function runResolver($ctx) { $vars = array('basedir' => $ctx->getAttribute('basedir', dirname($this->file->getRealPath())), 'phpDox.home' => $this->homeDir->getPathname(), 'phpDox.file' => $this->file->getPathname(), 'phpDox.version' => $this->version->getVersion(), 'phpDox.project.name' => $ctx->getAttribute('name', 'unnamed'), 'phpDox.project.source' => $ctx->getAttribute('source', 'src'), 'phpDox.project.workdir' => $ctx->getAttribute('workdir', 'xml'), 'phpDox.php.version' => PHP_VERSION); $protected = array_keys($vars); foreach ($ctx->query('cfg:property|/cfg:phpdox/cfg:property') as $property) { /** @var $property \DOMElement */ $name = $property->getAttribute('name'); $line = $property->getLineNo(); if (in_array($name, $protected)) { throw new ConfigException("Cannot overwrite system property in line {$line}", ConfigException::OverrideNotAllowed); } if (isset($vars[$name])) { throw new ConfigException("Cannot overwrite existing property '{$name}' in line {$line}", ConfigException::OverrideNotAllowed); } $vars[$name] = $this->resolveValue($property->getAttribute('value'), $vars, $line); } foreach ($ctx->query('.//*[not(name()="property")]/@*|@*') as $attr) { $attr->nodeValue = $this->resolveValue($attr->nodeValue, $vars, $attr->getLineNo()); } return $ctx; }
protected function runResolver($ctx) { if (defined('PHPDOX_VERSION') && constant('PHPDOX_VERSION') == '%development%') { $home = realpath(__DIR__ . '/../../'); } else { if (defined('PHPDOX_PHAR')) { $home = 'phar://' . constant('PHPDOX_PHAR'); } else { $home = realpath(__DIR__ . '/../'); } } $vars = array('basedir' => $ctx->getAttribute('basedir', $this->file->getPath()), 'phpDox.home' => $home, 'phpDox.file' => $this->file->getPathname(), 'phpDox.version' => Version::getVersion(), 'phpDox.project.name' => $ctx->getAttribute('name', 'unnamed'), 'phpDox.project.source' => $ctx->getAttribute('source', 'src'), 'phpDox.project.workdir' => $ctx->getAttribute('workdir', 'xml'), 'phpDox.php.version' => PHP_VERSION); $protected = array_keys($vars); foreach ($ctx->query('cfg:property|/cfg:phpdox/cfg:property') as $property) { /** @var $property \DOMElement */ $name = $property->getAttribute('name'); $line = $property->getLineNo(); if (in_array($name, $protected)) { throw new ConfigException("Cannot overwrite system property in line {$line}", ConfigException::OverrideNotAllowed); } if (isset($vars[$name])) { throw new ConfigException("Cannot overwrite existing property '{$name}' in line {$line}", ConfigException::OverrideNotAllowed); } $vars[$name] = $this->resolveValue($property->getAttribute('value'), $vars, $line); } foreach ($ctx->query('.//*[not(name()="property")]/@*|@*') as $attr) { $attr->nodeValue = $this->resolveValue($attr->nodeValue, $vars, $attr->getLineNo()); } return $ctx; }
public function resolverProvider() { $version = new Version('0.0'); return array('basedir' => array($this->baseDir . 'resolver', 'basedir'), 'phpDox.home' => array('/tmp', 'home'), 'phpDox.file' => array($this->baseDir . 'resolver/file.xml', 'file'), 'phpDox.version' => array($version->getVersion(), 'phpdox-version'), 'multi' => array('/tmp ' . $version->getVersion(), 'multi'), 'phpDox.project.name' => array('projectname', 'named'), 'phpDox.project.name[undefined]' => array('unnamed', 'named-undefined'), 'phpDox.project.workdir' => array('output', 'workdir'), 'phpDox.project.workdir[undefined]' => array('xml', 'workdir-undefined'), 'phpDox.php.version' => array(PHP_VERSION, 'php-version'), 'property-global' => array('propvalue', 'property-global'), 'property-project' => array('propvalue', 'property-project'), 'property-recursive' => array($version->getVersion(), 'property-recursive'), 'property-recursive-recursive' => array($this->baseDir . 'resolver/xml', 'property-recursive-recursive')); }
/** * Helper to output version information. */ protected function showVersion() { static $shown = FALSE; if ($shown) { return; } $shown = TRUE; echo Version::getInfoString() . "\n\n"; }