/**
  * Returns a method for a class by a given name
  *
  * @param   text.doclet.ClassDoc self
  * @param   string name
  * @return  text.doclet.MethodDoc
  * @throws  lang.ElementNotFoundException
  */
 public static function methodNamed(ClassDoc $self, $name)
 {
     foreach ($self->methods as $method) {
         if ($name === $method->name()) {
             return $method;
         }
     }
     raise('lang.ElementNotFoundException', 'No such method ' . $name . ' in ' . $self->name());
 }
Пример #2
0
 /** Add a class to this package.
  *
  * @param ClassDoc class
  */
 function addClass(ClassDoc $class)
 {
     if (isset($this->_classes[$class->name()])) {
         $phpdoctor = $this->_root->phpdoctor();
         echo "\n";
         $phpdoctor->warning('Found class ' . $class->name() . ' again, overwriting previous version');
     }
     $this->_classes[$class->name()] = $class;
 }
Пример #3
0
 /**
  * Generate class documentation for a given class and write it to the
  * given output stream
  *
  * @param   text.doclet.ClassDoc doc
  * @param   io.streams.OutputStream
  * @return  io.streams.OutputStream
  */
 protected function writeDoc(ClassDoc $doc, OutputStream $stream)
 {
     $this->writeHeader($doc->name(), $stream);
     $base = str_repeat('../', substr_count($doc->qualifiedName(), '.'));
     // Summary
     $stream->write('<h4><a href="' . $base . 'index.html">Overview</a>');
     $stream->write(' &#xbb; <a href="summary.html">' . $doc->containingPackage()->name() . '</a></h4>');
     $stream->write('<h1>' . ucfirst($doc->classType()) . ' ' . $doc->name() . '</h1>');
     $stream->write('<dl>');
     if ($doc->isInterface()) {
         $implementations = $this->classesImplementing($doc);
         if (!empty($implementations)) {
             $stream->write('<dt>All known implementing classes:</dt><dd>');
             for ($i = 0, $s = sizeof($implementations); $i < $s; $i++) {
                 $stream->write($this->typeLink($implementations[$i]->qualifiedName(), $base));
                 $i < $s - 1 && $stream->write(', ');
             }
             $stream->write('</dd>');
         }
     } else {
         $implemented = $this->allInterfacesImplementedBy($doc);
         if (!empty($implemented)) {
             $stream->write('<dt>All implemented interfaces:</dt><dd>');
             for ($i = 0, $s = sizeof($implemented); $i < $s; $i++) {
                 $stream->write($this->typeLink($implemented[$i]->qualifiedName(), $base));
                 $i < $s - 1 && $stream->write(', ');
             }
             $stream->write('</dd>');
         }
         $subclasses = $this->directSubclassesOf($doc);
         if (!empty($subclasses)) {
             $stream->write('<dt>Direct known subclasses:</dt><dd>');
             for ($i = 0, $s = sizeof($subclasses); $i < $s; $i++) {
                 $stream->write($this->typeLink($subclasses[$i]->qualifiedName(), $base));
                 $i < $s - 1 && $stream->write(', ');
             }
             $stream->write('</dd>');
         }
     }
     $stream->write('</dl>');
     $stream->write('<hr/>');
     // Signature
     $stream->write('<code>');
     $stream->write(implode(' ', array_keys($doc->getModifiers())) . ' ' . $doc->classType() . ' ' . $doc->name());
     if (!$doc->isInterface()) {
         $doc->superclass && $stream->write(' extends ' . $this->typeLink($doc->superclass->qualifiedName(), $base));
         $implemented = $this->interfacesImplementedBy($doc);
         if (!empty($implemented)) {
             $stream->write(' implements ');
             for ($i = 0, $s = sizeof($implemented); $i < $s; $i++) {
                 $stream->write($this->typeLink($implemented[$i]->qualifiedName(), $base));
                 $i < $s - 1 && $stream->write(', ');
             }
         }
     }
     $stream->write('</code>');
     $this->writeMarkup($doc->commentText(), $stream);
     // Class tags
     $stream->write('<dl>');
     $this->writeTags('See also', $doc->tags('see'), $base, $stream);
     $this->writeTags('Verified by', $doc->tags('test'), $base, $stream);
     $stream->write('</dl>');
     $stream->write('<hr/>');
     // Field summary
     $stream->write('<fieldset><legend>Fields Summary</legend><ul>');
     foreach ($doc->fields as $field) {
         $v = $field->constantValue();
         $stream->write('<li><code>');
         $stream->write($this->isStatic($field) ? 'static ' : '');
         $stream->write($field->name() . ($v ? ' = ' . $v : ''));
         $stream->write('</code><p>' . $this->firstSentence($field->commentText()) . '</p></li>');
     }
     $stream->write('</ul></fieldset>');
     // Method summary
     $stream->write('<fieldset><legend>Method Summary</legend><ul>');
     foreach ($doc->methods as $method) {
         $stream->write('<li><code>');
         $stream->write($this->isStatic($method) ? 'static ' : '');
         $this->writeSignature($method, $base, $stream);
         $stream->write('</code><p>' . $this->firstSentence($method->commentText()) . '</p></li>');
     }
     $stream->write('</ul></fieldset>');
     // Method details
     foreach ($doc->methods as $method) {
         $stream->write('<a name="' . $method->name() . '"><h3>' . $method->name() . '</h3></a>');
         $stream->write('<code>' . implode(' ', array_keys($method->getModifiers())) . ' ');
         $this->writeSignature($method, $base, $stream);
         $stream->write('</code><div class="dfn">');
         $this->writeMarkup($method->commentText(), $stream);
         $stream->write('<dl>');
         $this->writeTags('Parameters', $method->tags('param'), $base, $stream);
         $this->writeTags('Returns', $method->tags('return'), $base, $stream);
         $this->writeTags('Throws', $method->tags('throws'), $base, $stream);
         $this->writeTags('See also', $method->tags('see'), $base, $stream);
         $stream->write('</dl>');
         $stream->write('</div>');
         $stream->write('<hr/>');
     }
     $this->writeFooter($stream);
     return $stream;
 }
Пример #4
0
 /** Build the class hierarchy tree which is placed at the top of the page.
  *
  * @param RootDoc rootDoc The root doc
  * @param ClassDoc class Class to generate tree for
  * @param int depth Depth of recursion
  * @return mixed[]
  */
 function _buildTree(RootDoc $rootDoc, ClassDoc $class, $depth = NULL)
 {
     if ($depth === NULL) {
         $start = TRUE;
         $depth = 0;
     } else {
         $start = FALSE;
     }
     $output = '';
     $undefinedClass = FALSE;
     if ($class->superclass()) {
         echo "Class:" . $class->_name . " - Superclass: " . $class->superClass() . PHP_EOL;
         $superclass = $rootDoc->classNamed($class->superclass());
         if ($superclass) {
             $result = $this->_buildTree($rootDoc, $superclass, $depth);
             $output .= $result[0];
             $depth = ++$result[1];
         } else {
             $output .= $class->superclass() . '<br>';
             //$output .= str_repeat('   ', $depth).' └─';
             $output .= str_repeat('   ', $depth) . '&lfloor;&nbsp;';
             $depth++;
             $undefinedClass = TRUE;
         }
     }
     if ($depth > 0 && !$undefinedClass) {
         //$output .= str_repeat('   ', $depth).' └─';
         $output .= str_repeat('   ', $depth) . '&lfloor;&nbsp;';
     }
     if ($start) {
         $output .= '<strong>' . $class->name() . '</strong><br />';
     } else {
         $output .= '<a href="' . str_repeat('../', $this->_depth) . $class->asPath() . '">' . $class->name() . '</a><br>';
     }
     return array($output, $depth);
 }
Пример #5
0
 /**
  * Build the class tree branch for the given element
  *
  * @param ClassDoc[] tree
  * @param ClassDoc element
  */
 function _buildTree(array &$tree, ClassDoc $element)
 {
     $tree[$element->name()] = $element;
     if ($element->superclass()) {
         $rootDoc = $this->_doclet->rootDoc();
         $superclass = $rootDoc->classNamed($element->superclass());
         if ($superclass) {
             $this->_buildTree($tree, $superclass);
         }
     }
 }