상속: implements Zend\Code\Generator\GeneratorInterface
 /**
  * @param string|null $type
  *
  * @return string
  */
 private function generateTypeHint()
 {
     if (null === $this->type) {
         return '';
     }
     return $this->type->generate() . ' ';
 }
예제 #2
0
 /**
  * @return string
  */
 public function generate()
 {
     $output = '';
     $indent = $this->getIndentation();
     if (($docBlock = $this->getDocBlock()) !== null) {
         $docBlock->setIndentation($indent);
         $output .= $docBlock->generate();
     }
     $output .= $indent;
     if ($this->isAbstract()) {
         $output .= 'abstract ';
     } else {
         $output .= $this->isFinal() ? 'final ' : '';
     }
     $output .= $this->getVisibility() . ($this->isStatic() ? ' static' : '') . ' function ' . ($this->returnsReference ? '& ' : '') . $this->getName() . '(';
     $parameters = $this->getParameters();
     if (!empty($parameters)) {
         foreach ($parameters as $parameter) {
             $parameterOutput[] = $parameter->generate();
         }
         $output .= implode(', ', $parameterOutput);
     }
     $output .= ')';
     if ($this->returnType) {
         $output .= ' : ' . $this->returnType->generate();
     }
     if ($this->isAbstract()) {
         return $output . ';';
     }
     if ($this->isInterface()) {
         return $output . ';';
     }
     $output .= self::LINE_FEED . $indent . '{' . self::LINE_FEED;
     if ($this->body) {
         $output .= preg_replace('#^((?![a-zA-Z0-9_-]+;).+?)$#m', $indent . $indent . '$1', trim($this->body)) . self::LINE_FEED;
     }
     $output .= $indent . '}' . self::LINE_FEED;
     return $output;
 }
예제 #3
0
 /**
  * @param $implementedInterface
  * @return self
  */
 public function removeImplementedInterface($implementedInterface)
 {
     $implementedInterface = (string) TypeGenerator::fromTypeString($implementedInterface);
     unset($this->implementedInterfaces[array_search($implementedInterface, $this->implementedInterfaces)]);
     return $this;
 }