PHP: Hypertext Preprocessor (original) (raw)

`I think a more accurate explanation is this:

The Reflection classes are designed to reflect upon the source code of an application, not on any runtime information.

I think you misunderstand the ReflectionProperty constructor in your example above. The fact that it accepts an object as argument is just a convenience feature - you are actually inspecting the class of that object, not the object itself, so it's basically equivalent to:

Reflection=newReflectionProperty(getclass(Reflection = new ReflectionProperty(get_class(Reflection=newReflectionProperty(getclass(a), 'a');// throws exception Reflection=newReflectionProperty(getclass(Reflection = new ReflectionProperty(get_class(Reflection=newReflectionProperty(getclass(a), 'foo');?>

Getting the class of the object you're passing in is implied, since inspecting a defined property is the purpose of this class.

In your example, $a->foo is a dynamic member - it is not defined as a member of class, so there is no defining class reference, line number, default value, etc. - which means, there is nothing to reflect upon.

Clearly this very useful library could use some real documentation...

`