mirror of
https://github.com/php/php-src.git
synced 2026-03-24 08:12:21 +01:00
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.
20 lines
270 B
PHP
20 lines
270 B
PHP
--TEST--
|
|
Bug #37816 (ReflectionProperty does not throw exception when accessing protected attribute)
|
|
--FILE--
|
|
<?php
|
|
|
|
class TestClass
|
|
{
|
|
protected $p = 2;
|
|
}
|
|
|
|
$o = new TestClass;
|
|
|
|
$r = new ReflectionProperty($o, 'p');
|
|
|
|
var_dump($r->getValue($o));
|
|
|
|
?>
|
|
--EXPECT--
|
|
int(2)
|