1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 16:22:37 +01:00
Files
archived-php-src/ext/reflection/tests/bug72174.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

36 lines
578 B
PHP

--TEST--
Bug #72174: ReflectionProperty#getValue() causes __isset call
--FILE--
<?php
class Foo
{
private $bar;
public function __construct()
{
unset($this->bar);
}
public function __isset($name)
{
var_dump(__METHOD__);
return true;
}
public function __get($name)
{
var_dump(__METHOD__);
return $name;
}
}
$instance = new Foo();
$reflectionBar = (new ReflectionProperty(Foo::class, 'bar'));
var_dump($reflectionBar->getValue($instance));
?>
--EXPECT--
string(10) "Foo::__get"
string(3) "bar"