Oh my god, PHP.
For reasons I don’t understand, this does not work (ReflectionException ‘Class Foo does not have a property named prop’):
class Foo
{
protected static $prop = 'My value';
}
$ref = new ReflectionClass('Foo');
$prop = $ref->getStaticPropertyValue('prop');
However, this does:
$ref = new ReflectionClass('Foo');
$props = $ref->getStaticProperties();
$prop = $props['prop'];
This does not work; PHP cannot dereference array return values:
$props = $ref->getStaticProperties()['prop'];
This does not work; PHP cannot dereference objects from new instances:
$props = new ReflectionClass('Foo')->getStaticProperties();

October 29th, 2008 at 3:19 pm
First one seems like a bug. Did you report it?
October 29th, 2008 at 3:35 pm
@Joe Not yet. I’ll let you know when it’s closed as not a bug.
November 3rd, 2008 at 6:09 am
That’s just PHP showing you some tough love… like a father who pats his son on the head… while wearing a spiked glove…