Re: print_r unaware of object's read_property handler
| From: | Antony Dovgal | Date: | Thu, 15 Feb 2007 14:43:19 +0000 |
| Subject: | Re: print_r unaware of object's read_property handler | ||
| References: | 1 2 3 4 5 6 7 8 9 10 11 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-4534@lists.php.net to get a copy of this message | ||
On 02/15/2007 05:27 PM, Piotr Pokora wrote:
So "fails" means that property's value is not returned by print_r, though read_property hook seems to be ok as <?php echo $object->propA; ?> works fine.Yes, to read a property with the given name.Sure, you didn't add the properties to the hash.What read_property hook is used for? Return's property's zval?
Do you mind if I contribute and add something to ZEND2 docs?Of course I don't as long as it helps others.
"read_property - returns zval *, containing the value of the property. Is used when value of the property should be retrieved for reading.Right.
Keep in mind that ZEND2 engine doesn't use always your own defined read_property hook. Sometimes it uses only hash table returned by get_properties hook."Sometimes"? So it's like "today we'll use read_property().. ah, no, today is Friday, right? then we'll use get_properties()." ?
So if your extension requires object's property to be readable with every internal function , you must implemement your own hooks that way , so they update object's properties hash table. In other words it is not guaranteed, that your read_property hook will be always used by ZEND2 engine."Piotr, it's like saying "read_property() is used not always because in some cases write_property() is used". Pure nonsense, that's how I call it. -- Wbr, Antony Dovgal