示例#1
0
 /**
  * Sets a doc comment.
  *
  * @param string  $docComment  A DocComment value.
  * @param boolean $isFormated  A DocComment is formated (default false).
  */
 public function setDocComment($docComment, $isFormated = false)
 {
     if (!$isFormated) {
         $docComment = Stagehand_PHP_Class_CodeGenerator::formatDocComment($docComment);
     }
     $this->_docComment = $docComment;
 }
 /**
  * @test
  */
 public function createAbstractClassGenerator()
 {
     $class = new Stagehand_PHP_Class('Example');
     $class->defineAbstract();
     $generator = Stagehand_PHP_Class_CodeGenerator::create($class);
     $this->assertType('Stagehand_PHP_Class_CodeGenerator_AbstractClass', $generator);
 }
示例#3
0
 /**
  * Renders a method code.
  *
  * @return string
  */
 public function render()
 {
     if ($docComment = $this->getDocComment()) {
         $docComment .= "\n";
     }
     $code = sprintf($this->_getMethodFormat(), $docComment, $this->getVisibility(), $this->isStatic() ? ' static' : null, $this->isReference() ? '&' : null, $this->getName(), $this->_formatArguments($this->getArguments()), Stagehand_PHP_Class_CodeGenerator::indent($this->getCode()));
     if ($this->isFinal()) {
         $code = 'final ' . $code;
     }
     return $code;
 }
示例#4
0
 /**
  * Gets all constant's code.
  *
  * @return string
  */
 protected function _getAllConstantsCode()
 {
     $constants = $this->_class->getConstants();
     if (!count($constants)) {
         return;
     }
     $allConstantCodes = array();
     foreach ($constants as $constant) {
         if ($code = $this->_createConstantCode($constant)) {
             array_push($allConstantCodes, $code);
         }
     }
     return Stagehand_PHP_Class_CodeGenerator::indent(implode("\n", $allConstantCodes)) . "\n";
 }