/** * @param int $type * @param mixed $value */ public function modify($type, $value) { $this->type = (int) $type; $this->value = $value; if ($this->referencedTo) { $this->referencedTo->modify($type, $value); } }
public function testReferenceToChange() { /** * $a = 1; * $b = &$a; */ $parentVariable = new Variable('a', 1, CompiledExpression::INTEGER); $variable = new Variable('b', $parentVariable->getValue(), $parentVariable->getType()); static::assertFalse($variable->isReferenced()); $variable->setReferencedTo($parentVariable); static::assertTrue($variable->isReferenced()); static::assertSame($parentVariable, $variable->getReferencedTo()); /** * $b = 55.00 */ $variable->modify(CompiledExpression::DOUBLE, 55.0); static::assertSame($variable->getValue(), $parentVariable->getValue()); static::assertSame($variable->getType(), $parentVariable->getType()); }