Re: RFC: Locked Classes

From: Date: Sun, 10 Mar 2019 19:36:16 +0000
Subject: Re: RFC: Locked Classes
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-104627@lists.php.net to get a copy of this message
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]

« previous php.internals (#104627) next »