From:             irv at soundforsound dot co dot uk
Operating system: Linux
PHP version:      5CVS-2004-06-15 (dev)
PHP Bug Type:     Zend Engine 2 problem
Bug description:  ReflectionProperty getValue() fails on public static members

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}

-- 
Edit bug report at http://bugs.php.net/?id=28789&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28789&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28789&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28789&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28789&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28789&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28789&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28789&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28789&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28789&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28789&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28789&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28789&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28789&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28789&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28789&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28789&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28789&r=float

Reply via email to