/** * 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 useParsableValue() { $name = 'example'; $property = new Stagehand_PHP_Class_Property($name, 'Foo::value', true); $this->assertTrue($property->isParsable()); $this->assertEquals($property->getValue(), 'Foo::value'); $this->assertEquals($property->render(), 'public $example = Foo::value;'); $property->setValue('Foo::value'); $this->assertFalse($property->isParsable()); $this->assertEquals($property->getValue(), 'Foo::value'); $this->assertEquals($property->render(), 'public $example = \'Foo::value\';'); $property->setValue('Foo::value', true); $this->assertTrue($property->isParsable()); $this->assertEquals($property->getValue(), 'Foo::value'); $this->assertEquals($property->render(), 'public $example = Foo::value;'); }