Re: print_r unaware of object's read_property handler
| From: | Piotr Pokora | Date: | Thu, 15 Feb 2007 11:48:26 +0000 |
| Subject: | Re: print_r unaware of object's read_property handler | ||
| References: | 1 2 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-4515@lists.php.net to get a copy of this message | ||
antony@zend.com (Antony Dovgal) wrote:
> In order to use read_property() you need to know the name of the property.
Yes, I know and standard get_properties is perfectly fine wih this.
> print_r() and var_dump() output all properties of the object, they do not know their names,
> they have only the object itself.
That's why I ask. Those functions do not follow object's handler but instead use only
object's properties hash.
Yes I know it's returned by get_properties handler , but read_property is implemented for
reading property's value
so this handler should be used to get value instead of hash table value.
> Therefor you need to implement get_properties() hook to return a hash table with all object
> properties.
That's __very__ clear. If I have possibility to add get_properties hook and read_property hook
I should be able
to define own handler which returns properties names from get_properties and read every
property's value
using read_property hook as I already know property name. Am I wrong here?
> Which part of this explanation is not clear to you?
What I understand from your clarification is:
get_properties returns object's properties
read_property reads property knowing it's name
Do I understand it correct?
If yes, why print_r doesn't read property value using read_property hook, even if I add own
get_properties hook which
returns all properties names?
Yes, of course I can implement get_properties hook that way so it can updates object's
properties hash.
But my question is: do I need such functionality if my read_property ( and write ) hook doesn't
need object's properties hash?
Or better , do I need to duplicate every property's value in hash table because print_r
doesn't use my read_property handler?
A new question is:
What write_property handler hook should do?
Obvious answer is that such hook must update object's properties hash.
But why, if the only one purpose is print_r and var_dump functions?
And I think the last question:
When and why object's read_property hook is ignored?
Piotras