On 10/03/2019 18:56, Gabriel O wrote:
Isn’t unset() currently only way to remove reference? This part is hence very
problematic.
Hm, that's an interesting case to consider, thanks!
At the moment, the following code breaks the reference between $a->foo
and $bar, but also deletes the entire property from the instance:
class A { public $foo; }
$a = new A;
$a->foo =& $bar;
unset($a->foo);
var_dump($a->foo); # Notice: Undefined property: A::$foo
This feels very peculiar to me: $foo clearly *is* a defined property,
and I didn't want to over-ride the class definition, I just wanted to
"reset" that property. We can chalk it up to "references are bad", but
it is indeed problematic that there isn't an alternative way to say
"breakReference($a->foo);" that doesn't have this side effect.
Regards,
--
Rowan Collins
[IMSoP]
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php