|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-06-15 22:43 UTC] helly@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 11:00:02 2025 UTC |
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}