On 25 May 2016 at 21:13, Niklas Keller <[email protected]> wrote: > Unset can reset it to the default value, but wiping type information is > probably > not an option here. >
Wiping type info is indeed unwanted. As it currently stands, for example, un-setting a property and then re-assigning it retains its visibility properties, and doesn't destroy property information. See https://3v4l.org/pCmTV for an example (copied here for reference): <?php class Foo { private $bar = 'baz'; public function __construct() { unset($this->bar); } public function getFooBar() { return $this->bar; } } class Bar extends Foo { private $bar = 'baz'; public function __construct() { parent::__construct(); unset($this->bar); } public function getBarBar() { return $this->bar; } } $bar = new Bar(); var_dump($bar->getFooBar()); // notice + null var_dump($bar->getBarBar()); // notice + null $rBarBar = new ReflectionProperty(Foo::class, 'bar'); $rBarBar->setAccessible(true); $rBarBar->setValue($bar, __LINE__); var_dump($bar->getFooBar()); // line no. var_dump($bar->getBarBar()); // notice + null Marco Pivetta http://twitter.com/Ocramius http://ocramius.github.com/
