Re: [patch] Zend/zend_object_handlers.c - bug #29378 (foreach() doesn't work with arrays returned by __get)

From: Date: Thu, 16 Sep 2004 22:17:04 +0000
Subject: Re: [patch] Zend/zend_object_handlers.c - bug #29378 (foreach() doesn't work with arrays returned by __get)
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-12887@lists.php.net to get a copy of this message
Hello Stanislav, Thursday, September 16, 2004, 3:24:39 PM, you wrote: AD>>>> AD>>It looks like this bug was done intentionally (I'm not sure, just AD>>>> AD>an>assumption), so zend_std_get_property_ptr_ptr() doesn't call AD>>>> AD>__get. AD>>>> AD>>>> I'm not sure it should - this would confuse read/write operators like AD>>>> object increments. AD>>> AD>>>Hmm.. could you provide any examples? AD>>>I just want to test them with the patch and see maybe I can adopt it. > The idea is that when r/w operator tries to work on object property, he > can do it two ways: > 1. call get_ptr_ptr, receive actual zval and do whatever it wants on it > 2. some objects - like Java object representations, for example - can not > return actual zval for property. For them, get_ptr_ptr returns null and > then r/w operator call getter, does whatever it wants and calls setter on > it. > Now the question is what we want to do on the object having > getters/setters in PHP - do we want it to behave like 1 or like 2? I'd say > behaviour 2 is the most logical, since we don't even know if the getter > returns modifyable variable - and in most cases it won't, so if you have > some object $foo with getter and setter and you do $foo->x++, it should do > get, then ++ on the result and the set, since if you just do get and ++, > it probably won't have the necessary effect. That's a pretty nice solution. > We could approach this with another idea - making __get return reference > (of course, if code author feels it is the right thing to do) [...] Forget that, c-level __get implementations cannot return a zval by reference. Best regards, Marcus mailto:helly@php.net

« previous php.internals (#12887) next »