I sent this message to the php-general list and didn't get any
replies.  This seems to be a potential bug so I thought it would be
appropriate to the php-dev list.  Thank you for reading this message.

I have been using and experimenting with PHP 5's reflection API and
have ran into a wall.  I am trying to access static variables through
reflection but it seems as though they cannot be set.  The following
is some code that reproduces the problem.  Thanks to anyone that has
insight into my problem.

class ReflectionTest {
        public static $x=5;
}

$refl = new ReflectionClass('ReflectionTest');
$prop = $refl->getProperty('x');
//$prop->getValue(NULL); not valid!  need object
$obj = $refl->newInstance();
echo $prop->getValue($obj);

$prop->setValue($obj,8);//Won't work!  Static variables can't be set!
echo $prop->getValue($obj);

Output:
5
Fatal error: Uncaught exception 'ReflectionException' with message
'Cannot access non-public member' in C:\Program
Files\eclipse\workspace\PHPFlux\test.php:13 Stack trace: #0 {main}
thrown in C:\Program Files\eclipse\workspace\PHPFlux\test.php on line
13

Thank you,

Ben Dischinger

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to