|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28789 ReflectionProperty getValue() fails on public static members
Submitted: 2004-06-15 12:23 UTC Modified: 2004-06-15 22:43 UTC
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:3 (100.0%)
Same OS:2 (66.7%)
From: irv at soundforsound dot co dot uk Assigned: helly
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.0RC3 OS: *
Private report: No CVE-ID:
 [2004-06-15 12:23 UTC] irv at soundforsound dot co dot uk
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();

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}


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-15 22:43 UTC]
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
Thank you for the report, and for helping us make PHP better.

Still we cannot use getValue() on implicit or dynamic properties. (implicit properties require #26182 to be fixed
correctly first).
PHP Copyright © 2001-2015 The PHP Group
All rights reserved.
Last updated: Sun Nov 29 06:01:43 2015 UTC