Ejemplo n.º 1
0
 /**
  * @see Sphpdox\Element.Element::__toString()
  */
 public function __toString()
 {
     $name = $this->reflection->getName();
     $title = str_replace('\\', '\\\\', $name);
     //$title = $name;
     $string = str_repeat('-', strlen($title)) . "\n";
     $string .= $title . "\n";
     $string .= str_repeat('-', strlen($title)) . "\n\n";
     $string .= $this->getNamespaceElement();
     if ($this->reflection->isInterface()) {
         $string .= '.. php:interface:: ';
     } elseif ($this->reflection->isTrait()) {
         $string .= '.. php:trait:: ';
     } else {
         $string .= '.. php:class:: ';
     }
     $string .= $this->reflection->getShortName();
     $parser = $this->getParser();
     if ($description = $parser->getDescription()) {
         $string .= "\n\n";
         $string .= $this->indent($description, 4);
     }
     foreach ($this->getSubElements() as $element) {
         $e = $element->__toString();
         if ($e) {
             $string .= "\n\n";
             $string .= $this->indent($e, 4);
         }
     }
     $string .= "\n\n";
     // Finally, fix some whitespace errors
     $string = preg_replace('/^\\s+$/m', '', $string);
     $string = preg_replace('/ +$/m', '', $string);
     return $string;
 }
Ejemplo n.º 2
0
 /**
  * Add an interface for child
  *
  * @param string|ReflectionClass|ParsedClass $interface
  *
  * @throws \InvalidArgumentException If object is not an interface
  */
 public function addInterface($interface)
 {
     $interfaceName = $interface;
     if ($interface instanceof ReflectionClass || $interface instanceof ParsedClass) {
         if (!$interface->isInterface()) {
             throw new \InvalidArgumentException("Interface expected to add");
         }
         $interfaceName = $interface->name;
     }
     // Use absolute namespace to prevent NS-conflicts
     $this->interfaces[] = '\\' . ltrim($interfaceName, '\\');
 }
Ejemplo n.º 3
0
 /**
  *
  * @param ReflectionClass $reflection
  * @return string
  */
 protected static function getObjectType(ReflectionClass $reflection)
 {
     return $reflection->isTrait() ? "Trait" : ($reflection->isInterface() ? "Interface" : "Class");
 }