mirror of
https://github.com/php/php-src.git
synced 2024-11-23 18:04:36 +08:00
6e16e1daa9
With this patch, it is no longer required to call `ReflectionProperty#setAccessible()` or `ReflectionMethod#setAccessible()` with `true`. If a userland consumer already got to the point of accessing object/class information via reflection, it makes little sense for `ext/reflection` to disallow accessing `private`/`protected` symbols by default. After this patch, calling `ReflectionProperty#setAccessible(true)` or `ReflectionMethod#setAccessible(true)` on newly instantiated `ReflectionProperty` or `ReflectionMethod` respectively will have no effect. RFC: https://wiki.php.net/rfc/make-reflection-setaccessible-no-op Closes GH-5412.
35 lines
494 B
PHP
35 lines
494 B
PHP
--TEST--
|
|
Bug #72177 Scope issue in __destruct after ReflectionProperty::setValue()
|
|
--FILE--
|
|
<?php
|
|
class Child
|
|
{
|
|
protected $bar;
|
|
|
|
public function __destruct()
|
|
{
|
|
$this->bar = null;
|
|
}
|
|
}
|
|
|
|
class Parnt
|
|
{
|
|
protected $child;
|
|
|
|
public function doSomething()
|
|
{
|
|
$this->child = new Child();
|
|
|
|
$prop = new \ReflectionProperty($this, 'child');
|
|
$prop->setValue($this, null);
|
|
}
|
|
}
|
|
|
|
$p = new Parnt();
|
|
$p->doSomething();
|
|
|
|
echo "OK\n";
|
|
?>
|
|
--EXPECT--
|
|
OK
|