示例#1
0
 /**
  *  class_variable_declaration_4
  *    T_VARIABLE '=' static_scalar
  */
 protected function class_variable_declaration_4($params)
 {
     $name = $this->_getVariableName($params[0]->getValue());
     $property = new Stagehand_PHP_Class_Property($name);
     $lex = $this->getParser()->lex;
     $docComment = $lex->getLatestDocComment();
     if ($docComment) {
         $property->setDocComment($docComment, true);
     }
     if (is_array($params[2])) {
         $property->setValue(implode('', $params[2]), true);
     } else {
         $property->setValue($this->_getStaticScalarValue($params[2]));
     }
     return $property;
 }
    /**
     * @test
     */
    public function useDocComment()
    {
        $name = 'example';
        $docComment = "A tests for DocComment.\n\n@var example";
        $formatedDocComment = "/**\n * A tests for DocComment.\n *\n * @var example\n */";
        $result = <<<EOF
/**
 * A tests for DocComment.
 *
 * @var example
 */
public \$example;
EOF;
        $property = new Stagehand_PHP_Class_Property($name);
        $property->setDocComment($docComment);
        $this->assertEquals($property->getDocComment(), $formatedDocComment);
        $this->assertEquals($property->render(), $result);
        $docComment = "/**\n * A tests for DocComment.\n *\n * @var example\n */";
        $property->setDocComment($docComment, true);
        $this->assertEquals($property->getDocComment(), $formatedDocComment);
        $this->assertEquals($property->render(), $result);
    }