php.net |  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
Votes:3
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 (profile)
Status: Closed Package: Scripting Engine problem
PHP Version: 5.0.0RC3 OS: *
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: irv at soundforsound dot co dot uk
New email:
PHP Version: OS:

 

 [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 commitsRelated reports
 [2004-06-15 22:43 UTC] helly@php.net
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
http://snaps.php.net/.
 
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-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 18:01:31 2024 UTC