protected function _declar_class_constant($name, $scalar) { $constant = new Stagehand_PHP_Class_Constant($name); if (is_array($scalar)) { $constant->setValue(implode('', $scalar), true); } else { $constant->setValue($this->_getStaticScalarValue($scalar)); } $this->addCurrentConstant($constant); }
/** * Sets a constant. * * @param Stagehand_PHP_Class_Constant $constant */ public function setConstant(Stagehand_PHP_Class_Constant $constant) { $this->_constants[$constant->getName()] = $constant; }
/** * @test */ public function useParsableValue() { $foo = new Stagehand_PHP_Class_Constant('foo', 'Foo::value', true); $this->assertTrue($foo->isParsable()); $this->assertEquals($foo->getValue(), 'Foo::value'); $this->assertEquals($foo->render(), 'const foo = Foo::value;'); $foo->setValue('Foo::value'); $this->assertFalse($foo->isParsable()); $this->assertEquals($foo->getValue(), 'Foo::value'); $this->assertEquals($foo->render(), 'const foo = \'Foo::value\';'); $foo->setValue('Foo::value', true); $this->assertTrue($foo->isParsable()); $this->assertEquals($foo->getValue(), 'Foo::value'); $this->assertEquals($foo->render(), 'const foo = Foo::value;'); }