3v4l.org

run code in 300+ PHP versions simultaneously
--TEST-- Keeping a reference to an object property in an array should not override existing references ?> --FILE-- <?php class Container { /** @var \stdClass|null */ public $referencedProperty; public function __clone() { $this->referencedProperty = clone $this->referencedProperty; } } $references = []; $container = new Container(); $loadFieldByReference = function (& $referencedProperty) use (& $references) { $referencedProperty = new \stdClass(); $references[] = & $referencedProperty; }; $loadFieldByReference($container->referencedProperty); $container->referencedProperty->publicProperty = 123; $clone = clone $container; $clone->referencedProperty->publicProperty = 234; echo $container->referencedProperty->publicProperty, "\n"; echo $clone->referencedProperty->publicProperty, "\n"; echo $container->referencedProperty === $clone->referencedProperty ? "same\n" : "not same\n"; ?> --EXPECT-- 123 234 not same
Output for git.master, git.master_jit, rfc.property-hooks
--TEST-- Keeping a reference to an object property in an array should not override existing references ?> --FILE-- 234 234 same --EXPECT-- 123 234 not same

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
31.49 ms | 401 KiB | 8 Q