diff --git a/phpcs.xml b/phpcs.xml
new file mode 100644
index 00000000..f6fc2c03
--- /dev/null
+++ b/phpcs.xml
@@ -0,0 +1,40 @@
+
+
+ Arne Blankerts' coding standard
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/application.php b/src/application.php
index 8a64b7e5..e9a9d2b5 100644
--- a/src/application.php
+++ b/src/application.php
@@ -37,174 +37,174 @@
*/
namespace TheSeer\phpDox {
- use \TheSeer\fDom\fDomDocument;
-
- class Application {
-
- /**
- * Logger for progress and error reporting
- *
- * @var Logger
- */
- protected $logger;
-
- /**
- * Base path xml files are stored in
- *
- * @var string
- */
- protected $xmlDir;
-
- /**
- * Array of Container DOM Documents
- *
- * @var array
- */
- protected $container = array();
-
- /**
- * Constructor of PHPDox Application
- *
- * @param ProgressLogger $logger Instance of the ProgressLogger class
- * @param string $xmlDir Directory where (generated) xml files are stored in
- */
- public function __construct(ProgressLogger $logger, $xmlDir) {
- $this->logger = $logger;
- $this->xmlDir = $xmlDir;
- }
-
- /**
- * Run collection process on given directory tree
- *
- * @param string $srcDir Base path of source tree
- * @param DirectoryScanner $scanner A Directory scanner object to process
- * @param boolean $publicOnly Flag to enable processing of only public methods and members
- *
- * @return void
- */
- public function runCollector($srcDir, $scanner, $publicOnly = false) {
- $collector = new Collector(
+ use \TheSeer\fDom\fDomDocument;
+
+ class Application {
+
+ /**
+ * Logger for progress and error reporting
+ *
+ * @var Logger
+ */
+ protected $logger;
+
+ /**
+ * Base path xml files are stored in
+ *
+ * @var string
+ */
+ protected $xmlDir;
+
+ /**
+ * Array of Container DOM Documents
+ *
+ * @var array
+ */
+ protected $container = array();
+
+ /**
+ * Constructor of PHPDox Application
+ *
+ * @param ProgressLogger $logger Instance of the ProgressLogger class
+ * @param string $xmlDir Directory where (generated) xml files are stored in
+ */
+ public function __construct(ProgressLogger $logger, $xmlDir) {
+ $this->logger = $logger;
+ $this->xmlDir = $xmlDir;
+ }
+
+ /**
+ * Run collection process on given directory tree
+ *
+ * @param string $srcDir Base path of source tree
+ * @param DirectoryScanner $scanner A Directory scanner object to process
+ * @param boolean $publicOnly Flag to enable processing of only public methods and members
+ *
+ * @return void
+ */
+ public function runCollector($srcDir, $scanner, $publicOnly = false) {
+ $collector = new Collector(
$this->xmlDir,
$this->getContainerDocument('namespaces'),
$this->getContainerDocument('interfaces'),
$this->getContainerDocument('classes')
- );
- $collector->setPublicOnly($publicOnly);
- $collector->run($scanner, $this->logger);
- $this->cleanUp($srcDir);
- $this->saveContainer();
- }
-
- /**
- * Run Documentation generation process
- *
- * @param string $backend Name of the backend to use for generation
- * @param string $docDir Output directory to store documentation in
- * @param boolean $publicOnly Flag to enable processing of only public methods and members
- *
- * @return void
- */
- public function runGenerator($backend, $docDir, $publicOnly = false) {
- $generator = new Generator(
+ );
+ $collector->setPublicOnly($publicOnly);
+ $collector->run($scanner, $this->logger);
+ $this->cleanUp($srcDir);
+ $this->saveContainer();
+ }
+
+ /**
+ * Run Documentation generation process
+ *
+ * @param string $backend Name of the backend to use for generation
+ * @param string $docDir Output directory to store documentation in
+ * @param boolean $publicOnly Flag to enable processing of only public methods and members
+ *
+ * @return void
+ */
+ public function runGenerator($backend, $docDir, $publicOnly = false) {
+ $generator = new Generator(
$this->xmlDir,
$docDir,
$this->getContainerDocument('namespaces'),
$this->getContainerDocument('interfaces'),
$this->getContainerDocument('classes')
- );
- $generator->setPublicOnly($publicOnly);
- $generator->run($backend);
- }
-
- /**
- * Helper to load or create Container DOM Documents for namespaces, classes, interfaces, ...
- *
- * @param string $name name of the file (identical to root node)
- *
- * @return \TheSeer\fDom\fDomDocument
- */
- protected function getContainerDocument($name) {
- $fname = $this->xmlDir . '/' . $name .'.xml';
- if (isset($this->container[$fname])) {
- return $this->container[$fname];
- }
- $dom = new fDOMDocument('1.0', 'UTF-8');
- if (file_exists($fname)) {
- $dom->load($fname);
- } else {
- $rootNode = $dom->createElementNS('http://phpdox.de/xml#', $name);
- $dom->appendChild($rootNode);
- }
- $dom->registerNamespace('phpdox', 'http://phpdox.de/xml#');
- $dom->formatOutput = true;
- $this->container[$fname] = $dom;
- return $dom;
- }
-
- /**
- * Helper to save all known and (updated) container files.
- */
- protected function saveContainer() {
- foreach($this->container as $fname => $dom) {
- $dom->save($fname);
- }
- }
-
- /**
- * Helper to cleanup
- *
- * @param string $srcDir Source directory to compare xml structure with
- */
- protected function cleanup($srcDir) {
- $worker = new \RecursiveIteratorIterator(
+ );
+ $generator->setPublicOnly($publicOnly);
+ $generator->run($backend);
+ }
+
+ /**
+ * Helper to load or create Container DOM Documents for namespaces, classes, interfaces, ...
+ *
+ * @param string $name name of the file (identical to root node)
+ *
+ * @return \TheSeer\fDom\fDomDocument
+ */
+ protected function getContainerDocument($name) {
+ $fname = $this->xmlDir . '/' . $name .'.xml';
+ if (isset($this->container[$fname])) {
+ return $this->container[$fname];
+ }
+ $dom = new fDOMDocument('1.0', 'UTF-8');
+ if (file_exists($fname)) {
+ $dom->load($fname);
+ } else {
+ $rootNode = $dom->createElementNS('http://xml.phpdox.de/src#', $name);
+ $dom->appendChild($rootNode);
+ }
+ $dom->registerNamespace('phpdox', 'http://xml.phpdox.de/src#');
+ $dom->formatOutput = true;
+ $this->container[$fname] = $dom;
+ return $dom;
+ }
+
+ /**
+ * Helper to save all known and (updated) container files.
+ */
+ protected function saveContainer() {
+ foreach($this->container as $fname => $dom) {
+ $dom->save($fname);
+ }
+ }
+
+ /**
+ * Helper to cleanup
+ *
+ * @param string $srcDir Source directory to compare xml structure with
+ */
+ protected function cleanup($srcDir) {
+ $worker = new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($this->xmlDir, \FilesystemIterator::SKIP_DOTS),
\RecursiveIteratorIterator::CHILD_FIRST
- );
- $len = strlen($this->xmlDir);
- $srcPath = realpath($srcDir);
-
- if (strpos($srcDir, $srcPath) === 0) {
- $srcPath = '/';
- }
- else {
- $srcPath = dirname($srcPath) . '/';
- }
-
- $containers = array(
+ );
+ $len = strlen($this->xmlDir);
+ $srcPath = realpath($srcDir);
+
+ if (strpos($srcDir, $srcPath) === 0) {
+ $srcPath = '/';
+ }
+ else {
+ $srcPath = dirname($srcPath) . '/';
+ }
+
+ $containers = array(
$this->getContainerDocument('namespaces'),
$this->getContainerDocument('classes'),
$this->getContainerDocument('interfaces')
- );
+ );
- $whitelist = array(
+ $whitelist = array(
$this->xmlDir . '/namespaces.xml',
$this->xmlDir . '/classes.xml',
$this->xmlDir . '/interfaces.xml'
- );
-
- foreach($worker as $fname => $file) {
- $fname = $file->getPathname();
- if (in_array($fname, $whitelist)) {
- continue;
- }
- if ($file->isFile()) {
- $srcFile = $srcPath . substr($fname,$len+1,-4);
- if (!file_exists($srcFile)) {
- unlink($fname);
- foreach($containers as $dom) {
- foreach($dom->query("//phpdox:*[@src='{$srcFile}']") as $node) {
- $node->parentNode->removeChild($node);
- }
- }
- }
- } elseif ($file->isDir()) {
- $srcDir = $srcPath . substr($file->getPathname(),$len+1);
- if (!file_exists($srcDir)) {
- rmdir($fname);
- }
+ );
+
+ foreach($worker as $fname => $file) {
+ $fname = $file->getPathname();
+ if (in_array($fname, $whitelist)) {
+ continue;
+ }
+ if ($file->isFile()) {
+ $srcFile = $srcPath . substr($fname, $len+1, -4);
+ if (!file_exists($srcFile)) {
+ unlink($fname);
+ foreach($containers as $dom) {
+ foreach($dom->query("//phpdox:*[@src='{$srcFile}']") as $node) {
+ $node->parentNode->removeChild($node);
+ }
+ }
+ }
+ } elseif ($file->isDir()) {
+ $srcDir = $srcPath . substr($file->getPathname(), $len+1);
+ if (!file_exists($srcDir)) {
+ rmdir($fname);
+ }
+ }
}
- }
- }
+ }
- }
+ }
}
diff --git a/src/backend/genericbackend.php b/src/backend/genericbackend.php
index 3ddfd6a5..a33309f5 100644
--- a/src/backend/genericbackend.php
+++ b/src/backend/genericbackend.php
@@ -37,156 +37,156 @@
namespace TheSeer\phpDox {
- use \TheSeer\fDom\fDomDocument;
- use \TheSeer\fXSL\fXSLTProcessor;
- use \TheSeer\fXSL\fXSLCallback;
-
- abstract class genericBackend {
-
- private $generator = NULL;
- private $xsltproc = array();
-
- /**
- * Internal kickof method from generator
- *
- * @param Generator $generator Reference to a generator instance for callbacks
- *
- */
- final public function run(Generator $generator) {
- $this->generator = $generator;
- try {
- $this->build();
- } catch(\Exception $e) {
- // TODO: do we need to do any cleanup or logging here?
- throw $e;
- }
- }
-
- /**
- * Entry point to main processing logic
- *
- */
- abstract public function build();
-
- /**
- * Helper to get XSLTProcessor instance
- *
- * This method also registers the public methods of
- * the backend to be callable from within the xsl context
- *
- * @param \DomDocument $xsl A Stylesheet DOMDocument
- *
- * @return TheSeer\fXSL\fXSLTProcessor
- */
- protected function getXSLTProcessor(\DomDocument $xsl) {
- $hash = spl_object_hash($xsl);
- if (isset($this->xsltproc[$hash])) {
+ use \TheSeer\fDom\fDomDocument;
+ use \TheSeer\fXSL\fXSLTProcessor;
+ use \TheSeer\fXSL\fXSLCallback;
+
+ abstract class GenericBackend {
+
+ private $generator = NULL;
+ private $xsltproc = array();
+
+ /**
+ * Internal kickof method from generator
+ *
+ * @param Generator $generator Reference to a generator instance for callbacks
+ *
+ */
+ final public function run(Generator $generator) {
+ $this->generator = $generator;
+ try {
+ $this->build();
+ } catch(\Exception $e) {
+ // TODO: do we need to do any cleanup or logging here?
+ throw $e;
+ }
+ }
+
+ /**
+ * Entry point to main processing logic
+ *
+ */
+ abstract public function build();
+
+ /**
+ * Helper to get XSLTProcessor instance
+ *
+ * This method also registers the public methods of
+ * the backend to be callable from within the xsl context
+ *
+ * @param \DomDocument $xsl A Stylesheet DOMDocument
+ *
+ * @return TheSeer\fXSL\fXSLTProcessor
+ */
+ protected function getXSLTProcessor(\DomDocument $xsl) {
+ $hash = spl_object_hash($xsl);
+ if (isset($this->xsltproc[$hash])) {
+ return $this->xsltproc[$hash];
+ }
+
+ $cb = new fXSLCallback('http://phpdox.de/callback', 'cb');
+ $cb->setObject($this);
+ $cb->setBlacklist(array('run','build'));
+
+ $this->xsltproc[$hash] = new fXSLTProcessor($xsl);
+ $this->xsltproc[$hash]->registerCallback($cb);
+
return $this->xsltproc[$hash];
- }
-
- $cb = new fXSLCallback('http://phpdox.de/callback', 'cb');
- $cb->setObject($this);
- $cb->setBlacklist(array('run','build'));
-
- $this->xsltproc[$hash] = new fXSLTProcessor($xsl);
- $this->xsltproc[$hash]->registerCallback($cb);
-
- return $this->xsltproc[$hash];
- }
-
- /**
- * Forwarder to get $generator->getClassesAsDOM
- *
- * @return TheSeer\fDom\fDomDocument
- */
- protected function getClassesAsDOM() {
- return $this->generator->getClassesAsDOM();
- }
-
- /**
- * Forwarder to get $generator->getNamespaces
- *
- * @return TheSeer\fDom\fDomDocument
- */
- protected function getNamespaceAsDOM() {
- return $this->generator->getNamespacesAsDOM();
- }
-
- public function getClasses() {
- static $classes = NULL;
- if ($classes === NULL) {
- foreach($this->getClassesAsDOM()->query('//phpdox:class/@full') as $f) {
- $classes[] = $f->nodeValue;
+ }
+
+ /**
+ * Forwarder to get $generator->getClassesAsDOM
+ *
+ * @return TheSeer\fDom\fDomDocument
+ */
+ protected function getClassesAsDOM() {
+ return $this->generator->getClassesAsDOM();
+ }
+
+ /**
+ * Forwarder to get $generator->getNamespaces
+ *
+ * @return TheSeer\fDom\fDomDocument
+ */
+ protected function getNamespaceAsDOM() {
+ return $this->generator->getNamespacesAsDOM();
+ }
+
+ public function getClasses() {
+ static $classes = NULL;
+ if ($classes === NULL) {
+ foreach($this->getClassesAsDOM()->query('//phpdox:class/@full') as $f) {
+ $classes[] = $f->nodeValue;
+ }
}
- }
- return $classes;
- }
-
- public function getNamespaces() {
- static $namespaces = NULL;
- if ($namespaces === NULL) {
- foreach($this->getNamespacesAsDOM()->query('//phpdox:namespace/@name') as $n) {
- $namespaces[] = $n->nodeValue;
+ return $classes;
+ }
+
+ public function getNamespaces() {
+ static $namespaces = NULL;
+ if ($namespaces === NULL) {
+ foreach($this->getNamespacesAsDOM()->query('//phpdox:namespace/@name') as $n) {
+ $namespaces[] = $n->nodeValue;
+ }
}
- }
- return $namespaces;
- }
-
- public function getInterfaces() {
- static $interfaces = NULL;
- if ($interfaces === NULL) {
- foreach($this->getInterfacesAsDOM()->query('//phpdox:interface/@full') as $i) {
- $interfaces[] = $i->nodeValue;
+ return $namespaces;
+ }
+
+ public function getInterfaces() {
+ static $interfaces = NULL;
+ if ($interfaces === NULL) {
+ foreach($this->getInterfacesAsDOM()->query('//phpdox:interface/@full') as $i) {
+ $interfaces[] = $i->nodeValue;
+ }
}
- }
- return $this->interfaces;
- }
-
-
-
- /**
- * Forwarder to get $generator->getInterfaces
- *
- * @return TheSeer\fDom\fDomDocument
- */
- protected function getInterfacesAsDOM() {
- return $this->generator->getInterfacesAsDOM();
- }
-
-
- /**
- * Helper to get the DomDocument for a given classname
- *
- * @param string $class Classname as string
- *
- * @return TheSeer\fDom\DomDocument
- */
- protected function getXMLByClassName($class) {
- $f = $this->generator->getClassesAsDOM()->query("//phpdox:class[@full='$class']")->item(0);
- if (!$f) {
- // return empty warning dom?
- throw new \Exception("Class '$class' not found");
- }
- $filename = $f->getAttribute('xml');
- $d = new fDomDocument();
- $d->load($this->generator->getXMLDirectory() . '/' . $filename);
- return $d;
- }
-
- protected function saveDomDocument($dom, $filename) {
- $filename = $this->generator->getDocumentationDirectory() . '/' . $filename;
- $path = dirname($filename);
- clearstatcache();
- if (!file_exists($path)) {
- mkdir($path, 0755, true);
- }
- $dom->save($filename);
- }
-
- protected function classNameToFileName($class, $ext = 'xml') {
- return str_replace('\\','_', $class) . '.' . $ext;
- }
-
- }
+ return $this->interfaces;
+ }
+
+
+
+ /**
+ * Forwarder to get $generator->getInterfaces
+ *
+ * @return TheSeer\fDom\fDomDocument
+ */
+ protected function getInterfacesAsDOM() {
+ return $this->generator->getInterfacesAsDOM();
+ }
+
+
+ /**
+ * Helper to get the DomDocument for a given classname
+ *
+ * @param string $class Classname as string
+ *
+ * @return TheSeer\fDom\DomDocument
+ */
+ protected function getXMLByClassName($class) {
+ $f = $this->generator->getClassesAsDOM()->query("//phpdox:class[@full='$class']")->item(0);
+ if (!$f) {
+ // return empty warning dom?
+ throw new \Exception("Class '$class' not found");
+ }
+ $filename = $f->getAttribute('xml');
+ $d = new fDomDocument();
+ $d->load($this->generator->getXMLDirectory() . '/' . $filename);
+ return $d;
+ }
+
+ protected function saveDomDocument($dom, $filename) {
+ $filename = $this->generator->getDocumentationDirectory() . '/' . $filename;
+ $path = dirname($filename);
+ clearstatcache();
+ if (!file_exists($path)) {
+ mkdir($path, 0755, true);
+ }
+ $dom->save($filename);
+ }
+
+ protected function classNameToFileName($class, $ext = 'xml') {
+ return str_replace('\\', '_', $class) . '.' . $ext;
+ }
+
+ }
}
\ No newline at end of file
diff --git a/src/backend/htmlBuilder/class.xsl b/src/backend/htmlBuilder/class.xsl
index 3dc611eb..0b197bef 100644
--- a/src/backend/htmlBuilder/class.xsl
+++ b/src/backend/htmlBuilder/class.xsl
@@ -2,7 +2,7 @@
diff --git a/src/backend/htmlbuilder.php b/src/backend/htmlbuilder.php
index be71ca7d..5825cd52 100644
--- a/src/backend/htmlbuilder.php
+++ b/src/backend/htmlbuilder.php
@@ -37,22 +37,22 @@
namespace TheSeer\phpDox {
- use \TheSeer\fDom\fDomDocument;
+ use \TheSeer\fDom\fDomDocument;
- class htmlBuilder extends genericBackend {
+ class HtmlBuilder extends GenericBackend {
- public function build() {
- $tpl = new fDomDocument();
- $tpl->load(__DIR__.'/htmlBuilder/class.xsl');
- $xsl = $this->getXSLTProcessor($tpl);
+ public function build() {
+ $tpl = new fDomDocument();
+ $tpl->load(__DIR__.'/htmlBuilder/class.xsl');
+ $xsl = $this->getXSLTProcessor($tpl);
- foreach($this->getClasses() as $class) {
- $html = $xsl->transformToDoc($this->getXMLByClassName($class));
- $this->saveDomDocument($html, 'classes/'. $this->classNameToFileName($class,'xhtml'));
- }
+ foreach($this->getClasses() as $class) {
+ $html = $xsl->transformToDoc($this->getXMLByClassName($class));
+ $this->saveDomDocument($html, 'classes/'. $this->classNameToFileName($class, 'xhtml'));
+ }
- }
+ }
- }
+ }
}
\ No newline at end of file
diff --git a/src/builder.php b/src/builder.php
index 9b826543..7b1dcd19 100644
--- a/src/builder.php
+++ b/src/builder.php
@@ -37,95 +37,95 @@
namespace TheSeer\phpDox {
- use \pdepend\reflection\ReflectionSession;
- use \TheSeer\fDOM\fDOMDocument;
-
- class Builder {
-
- protected $publicOnly;
-
- protected $namespaces;
- protected $interfaces;
- protected $classes;
-
- protected $file;
- protected $dom;
-
- public function __construct($publicOnly = false) {
- $this->publicOnly = $publicOnly;
- }
-
- public function getClasses() {
- return $this->classes;
- }
-
- public function getInterfaces() {
- return $this->interfaces;
- }
-
- public function getNamespaces() {
- return $this->namespaces;
- }
-
- public function processFile(\SPLFileInfo $file) {
- $this->namespaces = array();
- $this->interfaces = array();
- $this->classes = array();
-
- $this->file = $file;
-
- $this->dom = new fDOMDocument('1.0', 'UTF-8');
- $this->dom->registerNamespace('dox', 'http://phpdox.de/xml#');
- $root = $this->dom->createElementNS('http://phpdox.de/xml#', 'file');
- $this->dom->appendChild($root);
-
- $head = $root->appendElementNS('http://phpdox.de/xml#', 'head');
- $head->setAttribute('path', $file->getPath());
- $head->setAttribute('file', $file->getFilename());
- $head->setAttribute('realpath', $file->getRealPath());
- $head->setAttribute('size', $file->getSize());
- $head->setAttribute('time', date('c', $file->getCTime()));
- $head->setAttribute('unixtime', $file->getCTime());
- $head->setAttribute('sha1', sha1_file($file->getPathname()));
-
- $session = new ReflectionSession();
- $session->addClassFactory( new \pdepend\reflection\factories\NullReflectionClassFactory() );
- $query = $session->createFileQuery();
- foreach ( $query->find( $file->getPathname() ) as $class ) {
- $this->handleClass($class);
- }
-
- return $this->dom;
- }
-
-
- protected function handleClass(\ReflectionClass $class) {
- $context = $this->dom->documentElement;
- if ($class->inNamespace()) {
- $context = $this->handleNamespace($class);
- }
-
- $classBuilder = new ClassBuilder($context, $this->publicOnly);
- $classNode = $classBuilder->process($class);
-
- if ($class->isInterface()) {
- $this->interfaces[$class->getName()] = $classNode;
- } else {
- $this->classes[$class->getName()] = $classNode;
- }
- }
-
- protected function handleNamespace(\ReflectionClass $class) {
- $namespace = $class->getNamespaceName();
- if (!isset($this->namespaces[$namespace])) {
- $nsNode = $this->dom->createElementNS('http://phpdox.de/xml#','namespace');
- $nsNode->setAttribute('name', $namespace);
- $this->dom->documentElement->appendChild($nsNode);
- $this->namespaces[$namespace] = $nsNode;
- }
- return $this->namespaces[$namespace];
- }
-
- }
+ use \pdepend\reflection\ReflectionSession;
+ use \TheSeer\fDOM\fDOMDocument;
+
+ class Builder {
+
+ protected $publicOnly;
+
+ protected $namespaces;
+ protected $interfaces;
+ protected $classes;
+
+ protected $file;
+ protected $dom;
+
+ public function __construct($publicOnly = false) {
+ $this->publicOnly = $publicOnly;
+ }
+
+ public function getClasses() {
+ return $this->classes;
+ }
+
+ public function getInterfaces() {
+ return $this->interfaces;
+ }
+
+ public function getNamespaces() {
+ return $this->namespaces;
+ }
+
+ public function processFile(\SPLFileInfo $file) {
+ $this->namespaces = array();
+ $this->interfaces = array();
+ $this->classes = array();
+
+ $this->file = $file;
+
+ $this->dom = new fDOMDocument('1.0', 'UTF-8');
+ $this->dom->registerNamespace('dox', 'http://xml.phpdox.de/src#');
+ $root = $this->dom->createElementNS('http://xml.phpdox.de/src#', 'file');
+ $this->dom->appendChild($root);
+
+ $head = $root->appendElementNS('http://xml.phpdox.de/src#', 'head');
+ $head->setAttribute('path', $file->getPath());
+ $head->setAttribute('file', $file->getFilename());
+ $head->setAttribute('realpath', $file->getRealPath());
+ $head->setAttribute('size', $file->getSize());
+ $head->setAttribute('time', date('c', $file->getCTime()));
+ $head->setAttribute('unixtime', $file->getCTime());
+ $head->setAttribute('sha1', sha1_file($file->getPathname()));
+
+ $session = new ReflectionSession();
+ $session->addClassFactory( new \pdepend\reflection\factories\NullReflectionClassFactory() );
+ $query = $session->createFileQuery();
+ foreach ( $query->find( $file->getPathname() ) as $class ) {
+ $this->handleClass($class);
+ }
+
+ return $this->dom;
+ }
+
+
+ protected function handleClass(\ReflectionClass $class) {
+ $context = $this->dom->documentElement;
+ if ($class->inNamespace()) {
+ $context = $this->handleNamespace($class);
+ }
+
+ $classBuilder = new ClassBuilder($context, $this->publicOnly);
+ $classNode = $classBuilder->process($class);
+
+ if ($class->isInterface()) {
+ $this->interfaces[$class->getName()] = $classNode;
+ } else {
+ $this->classes[$class->getName()] = $classNode;
+ }
+ }
+
+ protected function handleNamespace(\ReflectionClass $class) {
+ $namespace = $class->getNamespaceName();
+ if (!isset($this->namespaces[$namespace])) {
+ $nsNode = $this->dom->createElementNS('http://xml.phpdox.de/src#', 'namespace');
+ $nsNode->setAttribute('name', $namespace);
+ $this->dom->documentElement->appendChild($nsNode);
+ $this->namespaces[$namespace] = $nsNode;
+ }
+ return $this->namespaces[$namespace];
+ }
+
+ }
}
diff --git a/src/classbuilder.php b/src/classbuilder.php
index 19b583d7..0d45d6e7 100644
--- a/src/classbuilder.php
+++ b/src/classbuilder.php
@@ -37,184 +37,184 @@
namespace TheSeer\phpDox {
- use \TheSeer\fDOM\fDOMDocument;
- use \TheSeer\fDOM\fDOMElement;
- use \TheSeer\phpDox\DocBlock\Parser;
+ use \TheSeer\fDOM\fDOMDocument;
+ use \TheSeer\fDOM\fDOMElement;
+ use \TheSeer\phpDox\DocBlock\Parser;
- class ClassBuilder {
+ class ClassBuilder {
- protected $ctx;
- protected $publicOnly;
+ protected $ctx;
+ protected $publicOnly;
- public function __construct(fDOMElement $ctx, $publicOnly = false) {
- $this->ctx = $ctx;
- $this->publicOnly = $publicOnly;
- }
+ public function __construct(fDOMElement $ctx, $publicOnly = false) {
+ $this->ctx = $ctx;
+ $this->publicOnly = $publicOnly;
+ }
- public function process(\ReflectionClass $class) {
+ public function process(\ReflectionClass $class) {
- $node = $this->ctx->appendElementNS('http://phpdox.de/xml#', $class->isInterface() ? 'interface' : 'class' );
+ $node = $this->ctx->appendElementNS('http://xml.phpdox.de/src#', $class->isInterface() ? 'interface' : 'class' );
- $node->setAttribute('full', $class->getName());
- $node->setAttribute('name', $class->getShortName());
- $node->setAttribute('final', $class->isFinal() ? 'true' : 'false');
- if ($node->nodeName === 'class') {
- $node->setAttribute('abstract', $class->isAbstract() ? 'true' : 'false');
- }
-
- $node->setAttribute('start', $class->getStartLine());
- $node->setAttribute('end', $class->getEndLine());
-
- if ($docComment = $class->getDocComment()) {
- $node->appendChild(
- $this->processDocBlock($this->ctx->ownerDocument, $docComment)
- );
- }
+ $node->setAttribute('full', $class->getName());
+ $node->setAttribute('name', $class->getShortName());
+ $node->setAttribute('final', $class->isFinal() ? 'true' : 'false');
+ if ($node->nodeName === 'class') {
+ $node->setAttribute('abstract', $class->isAbstract() ? 'true' : 'false');
+ }
- if ($extends = $class->getParentClass()) {
- $this->addReferenceNode($extends, $node, 'extends');
- }
+ $node->setAttribute('start', $class->getStartLine());
+ $node->setAttribute('end', $class->getEndLine());
- $implements = $class->getInterfaces();
- if (count($implements)>0) {
- foreach($implements as $i) {
- $this->addReferenceNode($i, $node, 'implements');
+ if ($docComment = $class->getDocComment()) {
+ $node->appendChild(
+ $this->processDocBlock($this->ctx->ownerDocument, $docComment)
+ );
}
- }
- //var_dump($class->getConstant('ABC'));
- $this->processConstants($node, $class->getConstants());
- $this->processMembers($node, $class->getProperties());
- $this->processMethods($node, $class->getMethods());
-
- return $node;
-
- }
-
- protected function addReferenceNode(\ReflectionClass $class, fDOMElement $context, $nodeName) {
- $node = $context->appendElementNS('http://phpdox.de/xml#', $nodeName);
- $node->setAttribute($nodeName == 'extends' ? 'class' : 'interface', $class->getShortName());
- if ($class->inNamespace()) {
- $node->setAttribute('namespace', $class->getNamespaceName());
- }
- return $node;
- }
-
- protected function addModifiers(fDOMElement $ctx, $src) {
- $ctx->setAttribute('static', $src->isStatic() ? 'true' : 'false');
- if ($src->isPrivate()) {
- $ctx->setAttribute('visibility', 'private');
- } else if ($src->isProtected()) {
- $ctx->setAttribute('visibility', 'protected');
- } else {
- $ctx->setAttribute('visibility', 'public');
- }
- }
-
- protected function processDocBlock(fDOMDocument $doc, $comment) {
- try {
- $parser = new Parser();
- $docblock = $parser->parse($comment);
- return $docblock->asDom($doc);
- } catch (\Exception $e) {
- // TODO: Error logger -> addWarning
- //var_dump($comment);
- //throw $e;
- }
- }
-
- protected function processConstants(fDOMElement $ctx, Array $constants) {
- foreach($constants as $constant => $value) {
- $constNode = $ctx->appendElementNS('http://phpdox.de/xml#','constant');
- $constNode->setAttribute('name', $constant);
- $constNode->setAttribute('value', $value);
- }
- }
-
- protected function processMembers(fDOMElement $ctx, Array $members) {
- foreach($members as $member) {
- if ($this->publicOnly && ($member->isPrivate() || $member->isProtected())) {
- continue;
- }
- $memberNode = $ctx->appendElementNS('http://phpdox.de/xml#','member');
- $memberNode->setAttribute('name', $member->getName());
- $this->addModifiers($memberNode, $member);
- $this->processValue($memberNode, $member->getValue());
- if ($docComment = $member->getDocComment()) {
- $memberNode->appendChild(
- $this->processDocBlock($ctx->ownerDocument, $docComment)
- );
+
+ if ($extends = $class->getParentClass()) {
+ $this->addReferenceNode($extends, $node, 'extends');
}
- }
- }
- protected function processMethods(fDOMElement $ctx, Array $methods) {
- foreach($methods as $method) {
- if ($this->publicOnly && ($method->isPrivate() || $method->isProtected())) {
- continue;
+ $implements = $class->getInterfaces();
+ if (count($implements)>0) {
+ foreach($implements as $i) {
+ $this->addReferenceNode($i, $node, 'implements');
+ }
}
+ //var_dump($class->getConstant('ABC'));
+ $this->processConstants($node, $class->getConstants());
+ $this->processMembers($node, $class->getProperties());
+ $this->processMethods($node, $class->getMethods());
+
+ return $node;
- if ($method->isConstructor()) {
- $nodeName = 'constructor';
- } elseif ($method->isDestructor()) {
- $nodeName = 'destructor';
+ }
+
+ protected function addReferenceNode(\ReflectionClass $class, fDOMElement $context, $nodeName) {
+ $node = $context->appendElementNS('http://xml.phpdox.de/src#', $nodeName);
+ $node->setAttribute($nodeName == 'extends' ? 'class' : 'interface', $class->getShortName());
+ if ($class->inNamespace()) {
+ $node->setAttribute('namespace', $class->getNamespaceName());
+ }
+ return $node;
+ }
+
+ protected function addModifiers(fDOMElement $ctx, $src) {
+ $ctx->setAttribute('static', $src->isStatic() ? 'true' : 'false');
+ if ($src->isPrivate()) {
+ $ctx->setAttribute('visibility', 'private');
+ } else if ($src->isProtected()) {
+ $ctx->setAttribute('visibility', 'protected');
} else {
- $nodeName = 'method';
+ $ctx->setAttribute('visibility', 'public');
}
- $methodNode = $ctx->appendElementNS('http://phpdox.de/xml#', $nodeName);
- $methodNode->setAttribute('name', $method->getName());
- $methodNode->setAttribute('start', $method->getStartLine());
- $methodNode->setAttribute('end', $method->getEndLine());
- $methodNode->setAttribute('abstract', $method->isAbstract() ? 'true' : 'false');
- $methodNode->setAttribute('final', $method->isFinal() ? 'true' : 'false');
-
- $this->addModifiers($methodNode, $method);
-
- $docBlock = null;
- if ($docComment = $method->getDocComment()) {
- $docBlock = $this->processDocBlock($ctx->ownerDocument, $docComment);
- $methodNode->appendChild($docBlock);
+ }
+
+ protected function processDocBlock(fDOMDocument $doc, $comment) {
+ try {
+ $parser = new Parser();
+ $docblock = $parser->parse($comment);
+ return $docblock->asDom($doc);
+ } catch (\Exception $e) {
+ // TODO: Error logger -> addWarning
+ //var_dump($comment);
+ //throw $e;
}
- $this->processParameters($methodNode, $method->getParameters(), $docBlock);
-
- }
- }
-
- protected function processParameters(fDOMElement $ctx, Array $parameters, fDOMElement $docBlock = null) {
- foreach($parameters as $idx => $param) {
- $paramNode = $ctx->appendElementNS('http://phpdox.de/xml#', 'parameter');
- $paramNode->setAttribute('name', $param->getName());
- if ($class = $param->getClass()) {
- $paramNode->setAttribute('type','object');
- $paramNode->setAttribute('class', $class->getShortName());
- if ($class->inNamespace()) {
- $paramNode->setAttribute('namespace', $class->getNamespaceName());
- }
- } elseif ($param->isArray()) {
- $paramNode->setAttribute('type','array');
- } else {
- $paramNode->setAttribute('type', '{unknown}');
+ }
+
+ protected function processConstants(fDOMElement $ctx, Array $constants) {
+ foreach($constants as $constant => $value) {
+ $constNode = $ctx->appendElementNS('http://xml.phpdox.de/src#', 'constant');
+ $constNode->setAttribute('name', $constant);
+ $constNode->setAttribute('value', $value);
+ }
+ }
+
+ protected function processMembers(fDOMElement $ctx, Array $members) {
+ foreach($members as $member) {
+ if ($this->publicOnly && ($member->isPrivate() || $member->isProtected())) {
+ continue;
+ }
+ $memberNode = $ctx->appendElementNS('http://xml.phpdox.de/src#', 'member');
+ $memberNode->setAttribute('name', $member->getName());
+ $this->addModifiers($memberNode, $member);
+ $this->processValue($memberNode, $member->getValue());
+ if ($docComment = $member->getDocComment()) {
+ $memberNode->appendChild(
+ $this->processDocBlock($ctx->ownerDocument, $docComment)
+ );
+ }
}
- $paramNode->setAttribute('optional', $param->isOptional() ? 'true' : 'false');
- $paramNode->setAttribute('byreference', $param->isPassedByReference() ? 'true' : 'false');
- if ($param->isDefaultValueAvailable()) {
- $this->processValue($paramNode, $param->getDefaultValue());
+ }
+
+ protected function processMethods(fDOMElement $ctx, Array $methods) {
+ foreach($methods as $method) {
+ if ($this->publicOnly && ($method->isPrivate() || $method->isProtected())) {
+ continue;
+ }
+
+ if ($method->isConstructor()) {
+ $nodeName = 'constructor';
+ } elseif ($method->isDestructor()) {
+ $nodeName = 'destructor';
+ } else {
+ $nodeName = 'method';
+ }
+ $methodNode = $ctx->appendElementNS('http://xml.phpdox.de/src#', $nodeName);
+ $methodNode->setAttribute('name', $method->getName());
+ $methodNode->setAttribute('start', $method->getStartLine());
+ $methodNode->setAttribute('end', $method->getEndLine());
+ $methodNode->setAttribute('abstract', $method->isAbstract() ? 'true' : 'false');
+ $methodNode->setAttribute('final', $method->isFinal() ? 'true' : 'false');
+
+ $this->addModifiers($methodNode, $method);
+
+ $docBlock = null;
+ if ($docComment = $method->getDocComment()) {
+ $docBlock = $this->processDocBlock($ctx->ownerDocument, $docComment);
+ $methodNode->appendChild($docBlock);
+ }
+ $this->processParameters($methodNode, $method->getParameters(), $docBlock);
+
}
- /*
- if ($docBlock !== null) {
- $dpNode = $docBlock->query('//dox:parameter[@name="' . $param->getName() . '"]')->item(0);
- if ($dpNode) {
- $paramNode->appendChild($dpNode);
- }
+ }
+
+ protected function processParameters(fDOMElement $ctx, Array $parameters, fDOMElement $docBlock = null) {
+ foreach($parameters as $idx => $param) {
+ $paramNode = $ctx->appendElementNS('http://xml.phpdox.de/src#', 'parameter');
+ $paramNode->setAttribute('name', $param->getName());
+ if ($class = $param->getClass()) {
+ $paramNode->setAttribute('type', 'object');
+ $paramNode->setAttribute('class', $class->getShortName());
+ if ($class->inNamespace()) {
+ $paramNode->setAttribute('namespace', $class->getNamespaceName());
+ }
+ } elseif ($param->isArray()) {
+ $paramNode->setAttribute('type', 'array');
+ } else {
+ $paramNode->setAttribute('type', '{unknown}');
+ }
+ $paramNode->setAttribute('optional', $param->isOptional() ? 'true' : 'false');
+ $paramNode->setAttribute('byreference', $param->isPassedByReference() ? 'true' : 'false');
+ if ($param->isDefaultValueAvailable()) {
+ $this->processValue($paramNode, $param->getDefaultValue());
+ }
+ /*
+ if ($docBlock !== null) {
+ $dpNode = $docBlock->query('//dox:parameter[@name="' . $param->getName() . '"]')->item(0);
+ if ($dpNode) {
+ $paramNode->appendChild($dpNode);
+ }
+ }
+ */
}
- */
- }
- }
-
- protected function processValue(fDOMElement $ctx, $src) {
- $value = is_null($src) ? 'null' : var_export($src, true);
- $default = $ctx->appendElementNS('http://phpdox.de/xml#', 'default');
- $default->appendChild($ctx->ownerDocument->createTextnode($value));
- }
- }
+ }
+
+ protected function processValue(fDOMElement $ctx, $src) {
+ $value = is_null($src) ? 'null' : var_export($src, true);
+ $default = $ctx->appendElementNS('http://xml.phpdox.de/src#', 'default');
+ $default->appendChild($ctx->ownerDocument->createTextnode($value));
+ }
+ }
}
diff --git a/src/cli.php b/src/cli.php
index f4c8b639..3903b04a 100644
--- a/src/cli.php
+++ b/src/cli.php
@@ -42,205 +42,205 @@
*/
namespace TheSeer\phpDox {
- use \TheSeer\Tools\PHPFilterIterator;
- use \TheSeer\fDom\fDomDocument;
-
- class CLI {
-
- /**
- * Version identifier
- *
- * @var string
- */
- const VERSION = "%version%";
-
- /**
- * Main executor for CLI process.
- */
- public function run() {
- try {
- $input = new \ezcConsoleInput();
- $this->registerOptions($input);
- $input->process();
-
- if ($input->getOption('help')->value === true) {
- $this->showVersion();
- $this->showUsage();
- exit(0);
+ use \TheSeer\Tools\PHPFilterIterator;
+ use \TheSeer\fDom\fDomDocument;
+
+ class CLI {
+
+ /**
+ * Version identifier
+ *
+ * @var string
+ */
+ const VERSION = "%version%";
+
+ /**
+ * Main executor for CLI process.
+ */
+ public function run() {
+ try {
+ $input = new \ezcConsoleInput();
+ $this->registerOptions($input);
+ $input->process();
+
+ if ($input->getOption('help')->value === true) {
+ $this->showVersion();
+ $this->showUsage();
+ exit(0);
+ }
+
+ if ($input->getOption('version')->value === true) {
+ $this->showVersion();
+ exit(0);
+ }
+
+ if ($require = $input->getOption('require')->value) {
+ $this->processRequire($require);
+ }
+
+ if ($input->getOption('silent')->value === true) {
+ $logger = new ProgressLogger();
+ } else {
+ $this->showVersion();
+ $logger = new ShellProgressLogger();
+ }
+
+ $app = new Application($logger, $input->getOption('xml')->value);
+
+ if (!$input->getOption('generate')->value) {
+ $args = $input->getArguments();
+ $app->runCollector(
+ $args[0],
+ $this->getScanner($input),
+ $input->getOption('public')->value
+ );
+ }
+ if (!$input->getOption('collect')->value) {
+ $app->runGenerator(
+ $input->getOption('backend')->value,
+ $input->getOption('docs')->value,
+ $input->getOption('public')->value
+ );
+ }
+ } catch (\ezcConsoleException $e) {
+ $this->showVersion();
+ fwrite(STDERR, $e->getMessage()."\n\n");
+ $this->showUsage();
+ exit(3);
+ } catch (CLIException $e) {
+ $this->showVersion();
+ fwrite(STDERR, "Error while processing request:\n");
+ fwrite(STDERR, $e->getMessage()."\n");
+ exit(3);
+ } catch (\Exception $e) {
+ $this->showVersion();
+ fwrite(STDERR, "Error while processing request:\n");
+ fwrite(STDERR, ' - ' . $e."\n");
+ exit(1);
}
-
- if ($input->getOption('version')->value === true) {
- $this->showVersion();
- exit(0);
- }
-
- if ($require = $input->getOption('require')->value) {
- $this->processRequire($require);
+ }
+
+ /**
+ * Helper to load requested require files
+ *
+ * @param Array $require Array of files to require
+ */
+ protected function processRequire(Array $require) {
+ foreach($require as $file) {
+ if (!file_exists($file) || !is_file($file)) {
+ throw new CLIException("Require file '$file' not found or not a file", CLIException::RequireFailed);
+ }
+ require $file;
}
-
- if ($input->getOption('silent')->value === true) {
- $logger = new ProgressLogger();
+ }
+
+ /**
+ * Helper to get instance of DirectoryScanner with cli options applied
+ *
+ * @param ezcConsoleInput $input CLI Options pased to app
+ *
+ * @return Theseer\Tools\IncludeExcludeFilterIterator
+ */
+ protected function getScanner(\ezcConsoleInput $input) {
+ $scanner = new \TheSeer\Tools\DirectoryScanner;
+
+ $include = $input->getOption('include');
+ if (is_array($include->value)) {
+ $scanner->setIncludes($include->value);
} else {
- $this->showVersion();
- $logger = new ShellProgressLogger();
+ $scanner->addInclude($include->value);
}
- $app = new Application($logger, $input->getOption('xml')->value);
-
- if (!$input->getOption('generate')->value) {
- $args = $input->getArguments();
- $app->runCollector(
- $args[0],
- $this->getScanner($input),
- $input->getOption('public')->value
- );
- }
- if (!$input->getOption('collect')->value) {
- $app->runGenerator(
- $input->getOption('backend')->value,
- $input->getOption('docs')->value,
- $input->getOption('public')->value
- );
- }
- } catch (\ezcConsoleException $e) {
- $this->showVersion();
- fwrite(STDERR, $e->getMessage()."\n\n");
- $this->showUsage();
- exit(3);
- } catch (CLIException $e) {
- $this->showVersion();
- fwrite(STDERR, "Error while processing request:\n");
- fwrite(STDERR, $e->getMessage()."\n");
- exit(3);
- } catch (\Exception $e) {
- $this->showVersion();
- fwrite(STDERR, "Error while processing request:\n");
- fwrite(STDERR, ' - ' . $e."\n");
- exit(1);
- }
- }
-
- /**
- * Helper to load requested require files
- *
- * @param Array $require Array of files to require
- */
- protected function processRequire(Array $require) {
- foreach($require as $file) {
- if (!file_exists($file) || !is_file($file)) {
- throw new CLIException("Require file '$file' not found or not a file", CLIException::RequireFailed);
- }
- require $file;
- }
- }
-
- /**
- * Helper to get instance of DirectoryScanner with cli options applied
- *
- * @param ezcConsoleInput $input CLI Options pased to app
- *
- * @return Theseer\Tools\IncludeExcludeFilterIterator
- */
- protected function getScanner(\ezcConsoleInput $input) {
- $scanner = new \TheSeer\Tools\DirectoryScanner;
-
- $include = $input->getOption('include');
- if (is_array($include->value)) {
- $scanner->setIncludes($include->value);
- } else {
- $scanner->addInclude($include->value);
- }
-
- $exclude = $input->getOption('exclude');
- if ($exclude->value) {
- if (is_array($exclude->value)) {
- $scanner->setExcludes($exclude->value);
- } else {
- $scanner->addExclude($exclude->value);
+ $exclude = $input->getOption('exclude');
+ if ($exclude->value) {
+ if (is_array($exclude->value)) {
+ $scanner->setExcludes($exclude->value);
+ } else {
+ $scanner->addExclude($exclude->value);
+ }
}
- }
- $args = $input->getArguments();
- return $scanner($args[0]);
- }
+ $args = $input->getArguments();
+ return $scanner($args[0]);
+ }
- /**
- * Helper to output version information.
- */
- protected function showVersion() {
- printf("phpdox %s - Copyright (C) 2010 - 2011 by Arne Blankerts\n\n", self::VERSION);
- }
+ /**
+ * Helper to output version information.
+ */
+ protected function showVersion() {
+ printf("phpdox %s - Copyright (C) 2010 - 2011 by Arne Blankerts\n\n", self::VERSION);
+ }
- protected function registerOptions(\ezcConsoleInput $input) {
- $versionOption = $input->registerOption( new \ezcConsoleOption( 'v', 'version' ) );
- $versionOption->shorthelp = 'Prints the version and exits';
- $versionOption->isHelpOption = true;
+ protected function registerOptions(\ezcConsoleInput $input) {
+ $versionOption = $input->registerOption( new \ezcConsoleOption( 'v', 'version' ) );
+ $versionOption->shorthelp = 'Prints the version and exits';
+ $versionOption->isHelpOption = true;
- $helpOption = $input->registerOption( new \ezcConsoleOption( 'h', 'help' ) );
- $helpOption->isHelpOption = true;
- $helpOption->shorthelp = 'Prints this usage information';
+ $helpOption = $input->registerOption( new \ezcConsoleOption( 'h', 'help' ) );
+ $helpOption->isHelpOption = true;
+ $helpOption->shorthelp = 'Prints this usage information';
- $input->registerOption( new \ezcConsoleOption(
+ $input->registerOption( new \ezcConsoleOption(
'i', 'include', \ezcConsoleInput::TYPE_STRING, '*.php', true,
'File pattern to include (default: *.php)'
));
- $input->registerOption( new \ezcConsoleOption(
+ $input->registerOption( new \ezcConsoleOption(
'e', 'exclude', \ezcConsoleInput::TYPE_STRING, null, true,
'File pattern to exclude'
));
- $input->registerOption( new \ezcConsoleOption(
+ $input->registerOption( new \ezcConsoleOption(
'x', 'xml', \ezcConsoleInput::TYPE_STRING, './xml', false,
'Output directory for collected data (default: ./xml)'
));
- $input->registerOption( new \ezcConsoleOption(
+ $input->registerOption( new \ezcConsoleOption(
'd', 'docs', \ezcConsoleInput::TYPE_STRING, './docs', false,
'Output directory for generated documentation (default: ./docs)'
));
- $input->registerOption( new \ezcConsoleOption(
+ $input->registerOption( new \ezcConsoleOption(
'b', 'backend', \ezcConsoleInput::TYPE_STRING, 'htmlBuilder', false,
'Transformation/Processing backend to use (default: htmlBuilder)'
));
- $input->registerOption( new \ezcConsoleOption(
+ $input->registerOption( new \ezcConsoleOption(
'p', 'public', \ezcConsoleInput::TYPE_NONE, null, false,
'Only show public member and methods'
));
- $gen = $input->registerOption( new \ezcConsoleOption(
+ $gen = $input->registerOption( new \ezcConsoleOption(
'g', 'generate', \ezcConsoleInput::TYPE_NONE, null, false,
'No collecting, generate documentation only'
));
- $col = $input->registerOption( new \ezcConsoleOption(
+ $col = $input->registerOption( new \ezcConsoleOption(
'c', 'collect', \ezcConsoleInput::TYPE_NONE, null, false,
'Only collect data, do not generate docs'
));
- $gen->addExclusion(new \ezcConsoleOptionRule($col));
- $col->addExclusion(new \ezcConsoleOptionRule($gen));
+ $gen->addExclusion(new \ezcConsoleOptionRule($col));
+ $col->addExclusion(new \ezcConsoleOptionRule($gen));
- $input->registerOption( new \ezcConsoleOption(
+ $input->registerOption( new \ezcConsoleOption(
's', 'silent', \ezcConsoleInput::TYPE_NONE, null, false,
'Do not output anything to the console'
));
- $input->registerOption( new \ezcConsoleOption(
+ $input->registerOption( new \ezcConsoleOption(
'l', 'log', \ezcConsoleInput::TYPE_STRING, null, false,
'Generate XML style logfile'
));
- $input->registerOption( new \ezcConsoleOption(
+ $input->registerOption( new \ezcConsoleOption(
'r', 'require', \ezcConsoleInput::TYPE_STRING, null, true,
'Custom PHP Source file to load'
));
- $input->argumentDefinition = new \ezcConsoleArguments();
- $input->argumentDefinition[0] = new \ezcConsoleArgument( "directory" );
- $input->argumentDefinition[0]->shorthelp = "The directory to process.";
+ $input->argumentDefinition = new \ezcConsoleArguments();
+ $input->argumentDefinition[0] = new \ezcConsoleArgument( "directory" );
+ $input->argumentDefinition[0]->shorthelp = "The directory to process.";
- }
+ }
- /**
- * Helper to output usage information.
- */
- protected function showUsage() {
- print <<
-x, --xml Output directory for collected data (default: ./xml)
@@ -265,12 +265,12 @@ protected function showUsage() {
EOF;
- }
+ }
- }
+ }
- class CLIException extends \Exception {
- const RequireFailed = 1;
- }
+ class CLIException extends \Exception {
+ const RequireFailed = 1;
+ }
}
\ No newline at end of file
diff --git a/src/collector.php b/src/collector.php
index 1ba29496..2240e1ba 100644
--- a/src/collector.php
+++ b/src/collector.php
@@ -36,135 +36,137 @@
*/
namespace TheSeer\phpDox {
- use \TheSeer\Tools\PHPFilterIterator;
- use \TheSeer\fDOM\fDOMDocument;
-
- class Collector {
-
- protected $xmlDir;
-
- protected $publicOnly = false;
-
- protected $namespaces;
- protected $interfaces;
- protected $classes;
-
- /**
- * Collector constructor
- *
- * @param string $xmlDir Base path to store individual class files in
- * @param fDomDocument $nsDom DOM instance to register namespaces in
- * @param fDomDocument $iDom DOM instance to register interfaces in
- * @param fDomDocument $cDom DOM instance to register classes in
- */
- public function __construct($xmlDir, fDOMDocument $nsDom, fDOMDocument $iDom, fDOMDocument $cDom) {
- $this->xmlDir = $xmlDir;
- $this->namespaces = $nsDom;
- $this->interfaces = $iDom;
- $this->classes = $cDom;
- }
-
- public function setPublicOnly($switch) {
- $this->publicOnly = $switch === true;
- }
-
- /**
- * Main executer of the collector, looping over the iterator with found files
- *
- * @param \Iterator $scanner
- * @param Logger $logger
- */
- public function run(\Theseer\Tools\IncludeExcludeFilterIterator $scanner, $logger) {
-
- $worker = new PHPFilterIterator($scanner);
- $builder = new Builder($this->publicOnly);
-
- if (!file_exists($this->xmlDir)) {
- mkdir($this->xmlDir);
- }
-
- foreach($worker as $file) {
- $target = $this->setupTarget($file);
- if (file_exists($target) && filemtime($target)==$file->getMTime()) {
- $logger->progress('cached');
- continue;
+ use \TheSeer\Tools\PHPFilterIterator;
+ use \TheSeer\fDOM\fDOMDocument;
+
+ class Collector {
+
+ protected $xmlDir;
+
+ protected $publicOnly = false;
+
+ protected $namespaces;
+ protected $interfaces;
+ protected $classes;
+
+ /**
+ * Collector constructor
+ *
+ * @param string $xmlDir Base path to store individual class files in
+ * @param fDomDocument $nsDom DOM instance to register namespaces in
+ * @param fDomDocument $iDom DOM instance to register interfaces in
+ * @param fDomDocument $cDom DOM instance to register classes in
+ */
+ public function __construct($xmlDir, fDOMDocument $nsDom, fDOMDocument $iDom, fDOMDocument $cDom) {
+ $this->xmlDir = $xmlDir;
+ $this->namespaces = $nsDom;
+ $this->interfaces = $iDom;
+ $this->classes = $cDom;
+ }
+
+ public function setPublicOnly($switch) {
+ $this->publicOnly = $switch === true;
+ }
+
+ /**
+ * Main executer of the collector, looping over the iterator with found files
+ *
+ * @param \Iterator $scanner
+ * @param Logger $logger
+ */
+ public function run(\Theseer\Tools\IncludeExcludeFilterIterator $scanner, $logger) {
+
+ $worker = new PHPFilterIterator($scanner);
+ $builder = new Builder($this->publicOnly);
+
+ if (!file_exists($this->xmlDir)) {
+ mkdir($this->xmlDir);
}
- try {
- $xml = $builder->processFile($file);
- $xml->formatOutput= true;
- $xml->save($target);
- touch($target, $file->getMTime(), $file->getATime());
-
- $src = realpath($file->getPathName());
-
- $this->registerNamespaces($target, $src, $builder->getNamespaces());
- $this->registerInContainer($this->interfaces, 'interface', $target, $src, $builder->getInterfaces());
- $this->registerInContainer($this->classes, 'class', $target, $src, $builder->getClasses());
- $logger->progress('processed');
- } catch (\Exception $e) {
- $logger->progress('failed');
- var_dump($e);
- // TODO: Report Exception ;)
+
+ foreach($worker as $file) {
+ $target = $this->setupTarget($file);
+ if (file_exists($target) && filemtime($target)==$file->getMTime()) {
+ $logger->progress('cached');
+ continue;
+ }
+ try {
+ $xml = $builder->processFile($file);
+ $xml->formatOutput= true;
+ $xml->save($target);
+ touch($target, $file->getMTime(), $file->getATime());
+
+ $src = realpath($file->getPathName());
+
+ $this->registerNamespaces($target, $src, $builder->getNamespaces());
+ $this->registerInContainer($this->interfaces, 'interface', $target, $src, $builder->getInterfaces());
+ $this->registerInContainer($this->classes, 'class', $target, $src, $builder->getClasses());
+ $logger->progress('processed');
+ } catch (\Exception $e) {
+ $logger->progress('failed');
+ var_dump($e);
+ // TODO: Report Exception ;)
+ }
+ }
+
+ $logger->buildSummary();
+ }
+
+ protected function registerNamespaces($target, $src, array $list) {
+ foreach($list as $namespace) {
+ $name = $namespace->getAttribute('name');
+ $nsNode = $this->namespaces->query("//phpdox:namespace[@name='$name']")->item(0);
+ if (!$nsNode) {
+ $nsNode = $this->namespaces->documentElement->appendElementNS('http://xml.phpdox.de/src#', 'namespace');
+ $nsNode->setAttribute('name', $name);
+ }
+ $fNode = $this->namespaces->query("//phpdox:namespace[@name='$name']/phpdox:file[@src='$src']")->item(0);
+ if (!$fNode) {
+ $file = $nsNode->appendElementNS('http://xml.phpdox.de/src#', 'file');
+ $file->setAttribute('xml', $target);
+ $file->setAttribute('src', $src);
+ }
}
- }
-
- $logger->buildSummary();
- }
-
- protected function registerNamespaces($target, $src, array $list) {
- foreach($list as $namespace) {
- $name = $namespace->getAttribute('name');
- $nsNode = $this->namespaces->query("//phpdox:namespace[@name='$name']")->item(0);
- if (!$nsNode) {
- $nsNode = $this->namespaces->documentElement->appendElementNS('http://phpdox.de/xml#','namespace');
- $nsNode->setAttribute('name', $name);
+ }
+
+ protected function registerInContainer(fDomDocument $container, $nodeName, $target, $src, $list) {
+ foreach($container->query("//phpdox:*[@src='$src']") as $old) {
+ $old->parentNode->removeChild($old);
}
- $fNode = $this->namespaces->query("//phpdox:namespace[@name='$name']/phpdox:file[@src='$src']")->item(0);
- if (!$fNode) {
- $file = $nsNode->appendElementNS('http://phpdox.de/xml#','file');
- $file->setAttribute('xml', $target);
- $file->setAttribute('src', $src);
+ foreach($list as $srcNode) {
+ if ($srcNode->parentNode->localName == 'namespace') {
+ $ns = $srcNode->parentNode->getAttribute('name');
+ $ctx = $container->query("//phpdox:namespace[@name='$ns']")->item(0);
+ if (!$ctx) {
+ $ctx = $container->documentElement->appendElementNS('http://xml.phpdox.de/src#', 'namespace');
+ $ctx->setAttribute('name', $srcNode->parentNode->getAttribute('name'));
+ }
+ } else {
+ $ctx = $container->documentElement;
+ }
+ $workNode = $ctx->appendElementNS('http://xml.phpdox.de/src#', $nodeName);
+ foreach($srcNode->attributes as $attr) {
+ $workNode->appendChild($container->importNode($attr, true));
+ }
+ $workNode->setAttribute('xml', substr($target, strlen($this->xmlDir)+1));
+ $workNode->setAttribute('src', $src);
}
- }
- }
-
- protected function registerInContainer(fDomDocument $container, $nodeName, $target, $src, $list) {
- foreach($container->query("//phpdox:*[@src='$src']") as $old) {
- $old->parentNode->removeChild($old);
- }
- foreach($list as $srcNode) {
- if ($srcNode->parentNode->localName=='namespace') {
- $ns = $srcNode->parentNode->getAttribute('name');
- $ctx = $container->query("//phpdox:namespace[@name='$ns']")->item(0);
- if (!$ctx) {
- $ctx = $container->documentElement->appendElementNS('http://phpdox.de/xml#','namespace');
- $ctx->setAttribute('name', $srcNode->parentNode->getAttribute('name'));
- }
- } else {
- $ctx = $container->documentElement;
+ }
+
+ protected function setupTarget($file) {
+ $path = array();
+ foreach(explode('/', $file->getPathName()) as $part) {
+ if (($part == '.') || ($part == '')) {
+ continue;
+ }
+ $path[] = $part;
}
- $workNode = $ctx->appendElementNS('http://phpdox.de/xml#',$nodeName);
- foreach($srcNode->attributes as $attr) {
- $workNode->appendChild($container->importNode($attr,true));
+ $target = $this->xmlDir . '/' . join('/', $path).'.xml';
+ $targetDir = dirname($target);
+ clearstatcache();
+ if (!file_exists($targetDir)) {
+ mkdir($targetDir, 0755, true);
}
- $workNode->setAttribute('xml', substr($target, strlen($this->xmlDir)+1));
- $workNode->setAttribute('src', $src);
- }
- }
-
- protected function setupTarget($file) {
- $path = array();
- foreach(explode('/', $file->getPathName()) as $part) {
- if($part == '.' || $part == '') continue;
- $path[] = $part;
- }
- $target = $this->xmlDir . '/' . join('/',$path).'.xml';
- $targetDir = dirname($target);
- clearstatcache();
- if (!file_exists($targetDir)) {
- mkdir($targetDir,0755,true);
- }
- return $target;
- }
- }
+ return $target;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/docblock/docblock.php b/src/docblock/docblock.php
index 37cfee4e..724a1251 100644
--- a/src/docblock/docblock.php
+++ b/src/docblock/docblock.php
@@ -65,7 +65,7 @@ public function getEementByName($name) {
}
public function asDom(\TheSeer\fDOM\fDOMDocument $doc) {
- $node = $doc->createElementNS('http://phpdox.de/xml#', 'docblock');
+ $node = $doc->createElementNS('http://xml.phpdox.de/src#', 'docblock');
// add lines and such?
foreach($this->elements as $element) {
if (is_array($element)) {
diff --git a/src/docblock/element/descriptionelement.php b/src/docblock/element/descriptionelement.php
index 421f71ba..200745b3 100644
--- a/src/docblock/element/descriptionelement.php
+++ b/src/docblock/element/descriptionelement.php
@@ -53,7 +53,7 @@ public function asDom(\TheSeer\fDOM\fDOMDocument $ctx) {
if ($this->compact == '') {
return $ctx->createTextnode('');
}
- $node = $ctx->createElementNS('http://phpdox.de/xml#', 'description');
+ $node = $ctx->createElementNS('http://xml.phpdox.de/src#', 'description');
$node->setAttribute('compact', $this->compact);
if ($this->body != '') {
$node->appendChild($ctx->createTextnode($this->body));
diff --git a/src/docblock/element/genericelement.php b/src/docblock/element/genericelement.php
index eabc64c9..76b2d851 100644
--- a/src/docblock/element/genericelement.php
+++ b/src/docblock/element/genericelement.php
@@ -60,7 +60,7 @@ public function setBody($body) {
}
public function asDom(\TheSeer\fDOM\fDOMDocument $ctx) {
- $node = $ctx->createElementNS('http://phpdox.de/xml#', 'annotation');
+ $node = $ctx->createElementNS('http://xml.phpdox.de/src#', 'annotation');
$node->setAttribute('name', $this->name);
if ($this->value !== '') {
$node->setAttribute('value', $this->value);
diff --git a/src/docblock/element/paramelement.php b/src/docblock/element/paramelement.php
index ce0f397f..7ec752b1 100644
--- a/src/docblock/element/paramelement.php
+++ b/src/docblock/element/paramelement.php
@@ -56,7 +56,7 @@ public function setDescription($desc) {
}
public function asDom(\TheSeer\fDOM\fDOMDocument $ctx) {
- $node = $ctx->createElementNS('http://phpdox.de/xml#', 'param');
+ $node = $ctx->createElementNS('http://xml.phpdox.de/src#', 'param');
$node->setAttribute('name', $this->varname);
if ($this->type !== '') {
diff --git a/src/docblock/element/returnelement.php b/src/docblock/element/returnelement.php
index 9aa70a03..bbafb574 100644
--- a/src/docblock/element/returnelement.php
+++ b/src/docblock/element/returnelement.php
@@ -51,7 +51,7 @@ public function setDescription($desc) {
}
public function asDom(\TheSeer\fDOM\fDOMDocument $ctx) {
- $node = $ctx->createElementNS('http://phpdox.de/xml#', $this->name);
+ $node = $ctx->createElementNS('http://xml.phpdox.de/src#', $this->name);
$node->setAttribute('type', $this->type);
if ($this->description != '') {
diff --git a/src/docblock/parser.php b/src/docblock/parser.php
index e1f6a777..1962fdca 100644
--- a/src/docblock/parser.php
+++ b/src/docblock/parser.php
@@ -37,75 +37,75 @@
namespace TheSeer\phpDox\DocBlock {
- class Parser {
+ class Parser {
- protected $map = array(
- 'description' => 'TheSeer\\phpDox\\DocBlock\\DescriptionParser',
- 'param' => 'TheSeer\\phpDox\\DocBlock\\ParamParser',
- 'var' => 'TheSeer\\phpDox\\DocBlock\\ReturnParser',
- 'return' => 'TheSeer\\phpDox\\DocBlock\\ReturnParser'
- );
+ protected $map = array(
+ 'description' => 'TheSeer\\phpDox\\DocBlock\\DescriptionParser',
+ 'param' => 'TheSeer\\phpDox\\DocBlock\\ParamParser',
+ 'var' => 'TheSeer\\phpDox\\DocBlock\\ReturnParser',
+ 'return' => 'TheSeer\\phpDox\\DocBlock\\ReturnParser'
+ );
- protected $current;
+ protected $current;
- public function __construct(array $map = array()) {
- $this->map = array_merge($this->map, $map);
- }
+ public function __construct(array $map = array()) {
+ $this->map = array_merge($this->map, $map);
+ }
- public function parse($block) {
- $docBlock = new DocBlock();
- $lines = $this->prepare($block);
- $this->startParser('description');
- $buffer = array();
- foreach($lines as $line) {
- if ($line == '' || $line == '/') {
- if (count($buffer)) {
- $buffer[] = '';
- }
- continue;
- }
+ public function parse($block) {
+ $docBlock = new DocBlock();
+ $lines = $this->prepare($block);
+ $this->startParser('description');
+ $buffer = array();
+ foreach($lines as $line) {
+ if ($line == '' || $line == '/') {
+ if (count($buffer)) {
+ $buffer[] = '';
+ }
+ continue;
+ }
- if ($line[0]=='@') {
- $docBlock->appendElement(
- $this->current->getObject($buffer)
- );
- $buffer = array();
+ if ($line[0]=='@') {
+ $docBlock->appendElement(
+ $this->current->getObject($buffer)
+ );
+ $buffer = array();
- $lineParts = explode(' ', ltrim($line,'@'), 2);
- $name = $lineParts[0];
- $payload = ( isset( $lineParts[1] ) ? $lineParts[1] : '' );
+ $lineParts = explode(' ', ltrim($line, '@'), 2);
+ $name = $lineParts[0];
+ $payload = ( isset( $lineParts[1] ) ? $lineParts[1] : '' );
- $this->startParser($name, $payload);
- continue;
+ $this->startParser($name, $payload);
+ continue;
+ }
+ $buffer[] = $line;
}
- $buffer[] = $line;
- }
- $docBlock->appendElement(
- $this->current->getObject($buffer)
- );
- return $docBlock;
- }
+ $docBlock->appendElement(
+ $this->current->getObject($buffer)
+ );
+ return $docBlock;
+ }
- protected function prepare($block) {
- $block = str_replace(array("\r\n","\r"), "\n", $block);
- $raw = array();
- foreach(explode("\n", $block) as $line) {
- $raw[] = trim($line," *\n\t");
- }
- return $raw;
- }
+ protected function prepare($block) {
+ $block = str_replace(array("\r\n","\r"), "\n", $block);
+ $raw = array();
+ foreach(explode("\n", $block) as $line) {
+ $raw[] = trim($line, " *\n\t");
+ }
+ return $raw;
+ }
- protected function startParser($name, $payload = NULL) {
- if (isset($this->map[$name])) {
- $this->current = new $this->map[$name]($name);
- } else {
- $this->current = new GenericParser($name);
- }
- if ($payload !== NULL) {
- $this->current->setPayload($payload);
- }
- }
+ protected function startParser($name, $payload = NULL) {
+ if (isset($this->map[$name])) {
+ $this->current = new $this->map[$name]($name);
+ } else {
+ $this->current = new GenericParser($name);
+ }
+ if ($payload !== NULL) {
+ $this->current->setPayload($payload);
+ }
+ }
- }
+ }
-}
+}
\ No newline at end of file
diff --git a/src/docblock/parser/descriptionparser.php b/src/docblock/parser/descriptionparser.php
index 0c7a09d2..ddeb3a68 100644
--- a/src/docblock/parser/descriptionparser.php
+++ b/src/docblock/parser/descriptionparser.php
@@ -52,7 +52,7 @@ public function getObject(array $buffer) {
do {
$line = array_shift($buffer);
$compact .= ' ' . $line;
- } while ($line != '' && substr($line,-1)!='.');
+ } while ($line != '' && substr($line, -1) != '.');
$obj->setCompact(trim($compact));
$obj->setBody(trim(join("\n", $buffer)));
}
diff --git a/src/generator.php b/src/generator.php
index 2d6660df..56dc6b70 100644
--- a/src/generator.php
+++ b/src/generator.php
@@ -34,93 +34,92 @@
* @copyright Arne Blankerts , All rights reserved.
* @license BSD License
*/
-
namespace TheSeer\phpDox {
- use \TheSeer\fDOM\fDOMDocument;
- use \TheSeer\fXSL\fXSLTProcessor;
-
- class Generator {
- protected $xmlDir;
- protected $docDir;
-
- protected $publicOnly = false;
-
- protected $namespaces;
- protected $interfaces;
- protected $classes;
-
- /**
- * Generator constructor
- *
- * @param string $xmlDir Base path where class xml files are found
- * @param string $docDir Base directory to store documentation files in
- * @param fDomDocument $nsDom DOM instance to register namespaces in
- * @param fDomDocument $iDom DOM instance to register interfaces in
- * @param fDomDocument $cDom DOM instance to register classes in
- */
- public function __construct($xmlDir, $docDir, fDOMDocument $nsDom, fDOMDocument $iDom, fDOMDocument $cDom) {
- $this->xmlDir = $xmlDir;
- $this->docDir = $docDir;
-
- $this->namespaces = $nsDom;
- $this->interfaces = $iDom;
- $this->classes = $cDom;
- }
-
- public function setPublicOnly($switch) {
- $this->publicOnly = $switch;
- }
-
- public function isPublicOnly() {
- return $this->publicOnly;
- }
-
- public function getNamespacesAsDOM() {
- return $this->namespaces;
- }
-
- public function getInterfacesAsDOM() {
- return $this->interfaces;
- }
-
- public function getClassesAsDOM() {
- return $this->classes;
- }
-
- public function getXMLDirectory() {
- return $this->xmlDir;
- }
-
- public function getDocumentationDirectory() {
- return $this->docDir;
- }
-
- /**
- * Main executer of the generator
- *
- * @param string $class Classname of the backend implementation to use
- */
- public function run($class) {
- if (strpos('\\', $class)===false) {
- $class = 'TheSeer\\phpDox\\' . $class;
- }
-
- if (!class_exists($class, true)) {
- throw new GeneratorException("Backend class '$class' is not defined", GeneratorException::ClassNotDefined);
- }
- $backend = new $class();
- if (!$backend instanceof genericBackend) {
- throw new GeneratorException("'$class' must implement the GeneratorBackendInterface to be used as backend", GeneratorException::UnsupportedBackend);
- }
- $backend->run($this);
- }
-
- }
-
- class GeneratorException extends \Exception {
- const ClassNotDefined = 1;
- const UnsupportedBackend = 2;
- const UnexepctedType = 3;
- }
+ use \TheSeer\fDOM\fDOMDocument;
+ use \TheSeer\fXSL\fXSLTProcessor;
+
+ class Generator {
+ protected $xmlDir;
+ protected $docDir;
+
+ protected $publicOnly = false;
+
+ protected $namespaces;
+ protected $interfaces;
+ protected $classes;
+
+ /**
+ * Generator constructor
+ *
+ * @param string $xmlDir Base path where class xml files are found
+ * @param string $docDir Base directory to store documentation files in
+ * @param fDomDocument $nsDom DOM instance to register namespaces in
+ * @param fDomDocument $iDom DOM instance to register interfaces in
+ * @param fDomDocument $cDom DOM instance to register classes in
+ */
+ public function __construct($xmlDir, $docDir, fDOMDocument $nsDom, fDOMDocument $iDom, fDOMDocument $cDom) {
+ $this->xmlDir = $xmlDir;
+ $this->docDir = $docDir;
+
+ $this->namespaces = $nsDom;
+ $this->interfaces = $iDom;
+ $this->classes = $cDom;
+ }
+
+ public function setPublicOnly($switch) {
+ $this->publicOnly = $switch;
+ }
+
+ public function isPublicOnly() {
+ return $this->publicOnly;
+ }
+
+ public function getNamespacesAsDOM() {
+ return $this->namespaces;
+ }
+
+ public function getInterfacesAsDOM() {
+ return $this->interfaces;
+ }
+
+ public function getClassesAsDOM() {
+ return $this->classes;
+ }
+
+ public function getXMLDirectory() {
+ return $this->xmlDir;
+ }
+
+ public function getDocumentationDirectory() {
+ return $this->docDir;
+ }
+
+ /**
+ * Main executer of the generator
+ *
+ * @param string $class Classname of the backend implementation to use
+ */
+ public function run($class) {
+ if (strpos('\\', $class)===false) {
+ $class = 'TheSeer\\phpDox\\' . $class;
+ }
+
+ if (!class_exists($class, true)) {
+ throw new GeneratorException("Backend class '$class' is not defined", GeneratorException::ClassNotDefined);
+ }
+ $backend = new $class();
+ if (!$backend instanceof genericBackend) {
+ throw new GeneratorException("'$class' must implement the GeneratorBackendInterface to be used as backend", GeneratorException::UnsupportedBackend);
+ }
+ $backend->run($this);
+ }
+
+ }
+
+ class GeneratorException extends \Exception {
+ const ClassNotDefined = 1;
+ const UnsupportedBackend = 2;
+ const UnexepctedType = 3;
+ }
}
\ No newline at end of file
diff --git a/src/logger/progresslogger.php b/src/logger/progresslogger.php
index 21b5ab64..ca86c52b 100644
--- a/src/logger/progresslogger.php
+++ b/src/logger/progresslogger.php
@@ -37,40 +37,40 @@
*/
namespace TheSeer\phpDox {
- class ProgressLogger {
+ class ProgressLogger {
- protected $stateChars;
+ protected $stateChars;
- protected $totalCount = 0;
- protected $stateCount = array(
- 'processed' => 0,
- 'cached' => 0,
- 'failed' => 0
- );
+ protected $totalCount = 0;
+ protected $stateCount = array(
+ 'processed' => 0,
+ 'cached' => 0,
+ 'failed' => 0
+ );
- public function __construct($processed = '.', $cached = 'c', $failed = 'f') {
- $this->stateChars = array(
- 'processed' => $processed,
- 'cached' => $cached,
- 'failed' => $failed
- );
- }
+ public function __construct($processed = '.', $cached = 'c', $failed = 'f') {
+ $this->stateChars = array(
+ 'processed' => $processed,
+ 'cached' => $cached,
+ 'failed' => $failed
+ );
+ }
- public function progress($state) {
- if (!isset($this->stateChars[$state])) {
- throw new ProgressLoggerException("Unkown progress state '$state'", ShellLoggerException::UnkownState);
- }
- $this->stateCount[$state]++;
- $this->totalCount++;
- }
+ public function progress($state) {
+ if (!isset($this->stateChars[$state])) {
+ throw new ProgressLoggerException("Unkown progress state '$state'", ShellLoggerException::UnkownState);
+ }
+ $this->stateCount[$state]++;
+ $this->totalCount++;
+ }
- public function buildSummary() {
- }
+ public function buildSummary() {
+ }
- }
+ }
- class ProgressLoggerException extends \Exception {
- const UnknownState = 1;
- }
+ class ProgressLoggerException extends \Exception {
+ const UnknownState = 1;
+ }
-}
+}
\ No newline at end of file
diff --git a/src/logger/shellprogresslogger.php b/src/logger/shellprogresslogger.php
index 6441d3e5..f3ba2f56 100644
--- a/src/logger/shellprogresslogger.php
+++ b/src/logger/shellprogresslogger.php
@@ -37,23 +37,23 @@
*/
namespace TheSeer\phpDox {
- class ShellProgressLogger extends ProgressLogger {
+ class ShellProgressLogger extends ProgressLogger {
- public function progress($state) {
- parent::progress($state);
+ public function progress($state) {
+ parent::progress($state);
- echo $this->stateChars[$state];
- if ($this->totalCount % 50 == 0) {
- echo "\t[". $this->totalCount . "]\n";
- }
+ echo $this->stateChars[$state];
+ if ($this->totalCount % 50 == 0) {
+ echo "\t[". $this->totalCount . "]\n";
+ }
- }
+ }
- public function buildSummary() {
- echo "\n\n";
- }
+ public function buildSummary() {
+ echo "\n\n";
+ }
- }
+ }
-}
+}
\ No newline at end of file