ReflectionProperty change between 5.1 and 5.2
| From: | Morten Fangel | Date: | Fri, 03 Nov 2006 10:03:06 +0000 |
| Subject: | ReflectionProperty change between 5.1 and 5.2 | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-26296@lists.php.net to get a copy of this message | ||
Hi,
Lets say I have a class
class MyClass
protected $foo = 'bar';
}
In PHP 5.1 I could do
$myobj = new MyClass();
$c = new ReflectionClass($myobj);
$p = $c->getProperty('foo');
echo $p->getValue($myobj); // bar
But in PHP 5.2 I now get an exception with "Cannot access non-public member
MyClass::foo"
Yes, I do know that "protected" is supposed to make the variable internal
(hence non-public), but shouldn't the ReflectionAPI enable one to "reverse
engineer" all classes and properties - including the ones hidden in run-time?
And if not, then how come it was like this in 5.1?
-fangel