php-src/Zend/tests/bug72177.phpt
Marco Pivetta 6e16e1daa9 Make ReflectionProperty/Method always accessible
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.
2021-07-08 10:55:38 +02:00

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