ReflectionProperty getValue() fails on public static members
| Bug #28789 | ReflectionProperty getValue() fails on public static members | |||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Submitted: | 2004-06-15 12:23 UTC | Modified: | 2004-06-15 22:43 UTC |
|
||||||||||
| From: | irv at soundforsound dot co dot uk | Assigned: | helly (profile) | |||||||||||
| Status: | Closed | Package: | Scripting Engine problem | |||||||||||
| PHP Version: | 5.0.0RC3 | OS: | * | |||||||||||
| Private report: | No | CVE-ID: | None | |||||||||||
[2004-06-15 12:23 UTC] irv at soundforsound dot co dot uk
Description:
------------
Unless I misunderstand the (scarce) documentation, using ReflectionProperty's getValue() should work on all public properties but should throw an exception on private or protected. I guess the getValue() method just checks for the numerical value of public and not public static (257 i think?).
Reproduce code:
---------------
class String
{
public static $fails = 5;
public $works = 5;
}
$prop1= new ReflectionProperty('String', 'works');
$prop2= new ReflectionProperty('String', 'fails');
$obj= new String();
//works
var_dump($prop1->getValue($obj));
//exception
var_dump($prop2->getValue($obj));
Expected result:
----------------
prints "int(5)"
Actual result:
--------------
Fatal error: Uncaught exception 'ReflectionException' with message 'Cannot access non-public member' in /home/irv/public_html/pureswank/src/reftest.php:74 Stack trace: #0 {main}
Patches
Pull Requests
History
AllCommentsChangesGit/SVN commits
[2004-06-15 22:43 UTC] helly@php.net