PHPSA\Variable::getReferencedTo PHP Method

getReferencedTo() public method

public getReferencedTo ( ) : null | Variable
return null | Variable
    public function getReferencedTo()
    {
        return $this->referencedTo;
    }

Usage Example

Example #1
0
 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());
 }