y = 0; } public function changeY(int $newValue): bool { if ($newValue == $this->y) return false; $this->y = $newValue; return true; } } class foo { public int $x; public object $copy; public function __construct() { $this->x = 1; $this->copy = new stdClass(); } public function changeX(int $newValue = 1): bool { if ($newValue == $this->x) return false; $this->x = $newValue; return true; } } $original = new foo(); echo 'Value of original->x: ' . $original->x . PHP_EOL; echo 'Value of original->x was ' . ($original->changeX(10)) ? '' : 'not '; echo 'changed.' . PHP_EOL; // assign the reference $original->copy =& $original; echo 'Value of copy->x ' . $original->copy->changeX(10) ? '' : 'not '; echo 'changed.' . PHP_EOL; echo 'value of original->copy->x: ' . $original->copy->x . PHP_EOL; // reassign the object $original->copy to the class object $argle $objectTwo = new bar(); $original->copy =& $objectTwo; // note that even though $original->copy is decl as type object, we can still assign another object, of type argle // to the member AND access that member's functions without generating a warning! if ($original->copy->changeY(10)) echo 'original->copy value changed!' . PHP_EOL; else echo 'original->copy unchanged' . PHP_EOL; echo 'value of original->copy->y: ' . $original->copy->y . PHP_EOL;