Re: print_r unaware of object's read_property handler

From: Date: Thu, 15 Feb 2007 13:49:07 +0000
Subject: Re: print_r unaware of object's read_property handler
References: 1 2 3 4 5 6 7  Groups: php.pecl.dev 
Request: Send a blank email to pecl-dev+get-4525@lists.php.net to get a copy of this message
On 02/15/2007 04:23 PM, Piotr Pokora wrote:
antony@zend.com (Antony Dovgal) wrote: Is get_properties hook designed to return properties names with values?
Yes.
Is this acceptable if get_properties return only names of properties?
Sure, as long as it works for you.
Or is this an issue of my handler that print_r will not print values in such case?
It depends on whether you care about it or not. So it's absolutely up to you.
If one of my hooks updates object's properties ( both keys and values ) , is this kind of overloading if I return zval using read_property and zval is not returned from object's properties?
In such scenario , every OOP code works , except print_r.
Could you finally tell us what exactly is wrong there, so we can switch to the real problem instead of wasting your and our time on a non-existent one?
Because calling one function per operation is better then calling X functions, where X is the number of properties.
You mean hash_find VS get_properties and read_properties ?
I mean get_properties() VS get_properties() + read_properties()*number_of_properties.
print_r is rather not used in production environments and every developer would expect consistency here.
So we've come to the inconsistency again. Looks like we're going in circles..
Do you want to tell me "Yes , it's exception and we do not use read_property hook here" ?
No, it's not an exception because you misunderstand the rule. I told you several times that get_properties() returns both name and values. What function is used in get_properties() and whether it's the same function which is used in read_property() - it's up to your implementation.
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?
Because get_properties() returns both names and values of the properties, we don't need to call read_property(), we already have the value in the has returned from get_properties().
So get_properties and write_property hook should be enough?
Which part of the sentence makes you think so?
"Because get_properties() returns both names and values of the properties"
Do you understand that get_properties(), read_property() and write_property() do completely different things and called in different cases? You want read_property() to be used in print_r(). I said fine, where are you going to take the name of the property? You said you can use get_properties() for that. Great, I said. But why do you need to call read_property() then? get_properties() returns the value too. And now you're asking why do you need read_property() at all. Looks like you don't understand something basic, but I haven't yet found what exactly. -- Wbr, Antony Dovgal

« previous php.pecl.dev (#4525) next »