note 99147 added to class.reflectionproperty
| From: | rasmus at mindplay dot dk | Date: | Fri, 30 Jul 2010 12:06:14 +0000 |
| Subject: | note 99147 added to class.reflectionproperty | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-171223@lists.php.net to get a copy of this message | ||
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:
<?php
// works fine
$Reflection = new ReflectionProperty(get_class($a), 'a');
// throws exception
$Reflection = new ReflectionProperty(get_class($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...
----
Server IP: 69.147.83.197
Probable Submitter: 67.249.192.161
----
Manual Page -- http://www.php.net/manual/en/class.reflectionproperty.php
Edit -- https://master.php.net/note/edit/99147
Del: integrated -- https://master.php.net/note/delete/99147/integrated
Del: useless -- https://master.php.net/note/delete/99147/useless
Del: bad code -- https://master.php.net/note/delete/99147/bad+code
Del: spam -- https://master.php.net/note/delete/99147/spam
Del: non-english -- https://master.php.net/note/delete/99147/non-english
Del: in docs -- https://master.php.net/note/delete/99147/in+docs
Del: other reasons-- https://master.php.net/note/delete/99147
Reject -- https://master.php.net/note/reject/99147
Search -- https://master.php.net/manage/user-notes.php