[PROPOSAL] Change (just slightly) read/write_property() and get_property_ptr_ptr() usage

php.internals

Michael Wallner

19 years ago
Hi, I'd like to suggest a change to how the read_property object handler operates. Wouldn't it be reasonable for the engine to use get_property_ptr_ptr() whenever it wants to modify a property and get rid of using read_property() for write access? That would make rather simple ops like concatenation, in-/decrementation etc work again with overloaded internal classes. Just make the engine use read_property() followed by a write_property() when there's no get_property_ptr_ptr(). Punish me if I'm really that far off. Thoughts?
-- Michael

Peter Hodge

19 years ago
Hello, Does that fix the problem where: $object->theArray[] = (...); is invalid when 'theArray' is implemented using __get()? Whoever fixes that one could get all free drinks at PHP conferences: PHP Hacker: "Hi, I'm the guy who made it so you can add items to an array which is returned through __get()" PHP Fanboy: "Dude that is so awesome, how could I ever repay you!? Can I buy you a beer?" regards, Peter --- Michael Wallner <mike@php.net> wrote:
> Hi, > > I'd like to suggest a change to how the read_property object handler > operates. > > Wouldn't it be reasonable for the engine to use get_property_ptr_ptr() > whenever > it wants to modify a property and get rid of using read_property() for write > access? > > That would make rather simple ops like concatenation, in-/decrementation etc > work again with overloaded internal classes. Just make the engine use > read_property() followed by a write_property() when there's no > get_property_ptr_ptr(). > > Punish me if I'm really that far off. > > Thoughts? > -- > Michael > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
Send instant messages to your online friends http://au.messenger.yahoo.com

Antony Dovgal

19 years ago
On 02/19/2007 02:23 PM, Peter Hodge wrote:
> Hello, > > Does that fix the problem where: > > $object->theArray[] = (...); > > is invalid when 'theArray' is implemented using __get()? > > Whoever fixes that one could get all free drinks at PHP conferences: > > PHP Hacker: "Hi, I'm the guy who made it so you can add items to an array which > is returned through __get()" > PHP Fanboy: "Dude that is so awesome, how could I ever repay you!? Can I buy > you a beer?"
I believe you can start buying drinks for Dmitry =) This code: <?php class test { private $var = array(); function &__get($name) { /* note the & */ return $this->$name; } } $t = new test; $t->var[] = "first"; $t->var[][] = "second"; $t->var[][][] = "third"; var_dump($t); ?> produces the following output: object(test)#1 (1) { ["var:private"]=> array(3) { [0]=> string(5) "first" [1]=> array(1) { [0]=> string(6) "second" } [2]=> array(1) { [0]=> array(1) { [0]=> string(5) "third" } } } }
-- Wbr, Antony Dovgal

Peter Hodge

19 years ago
--- Antony Dovgal <antony@zend.com> wrote:
> On 02/19/2007 02:23 PM, Peter Hodge wrote: > > Hello, > > > > Does that fix the problem where: > > > > $object->theArray[] = (...); > > > > is invalid when 'theArray' is implemented using __get()? > > > > Whoever fixes that one could get all free drinks at PHP conferences: > > > > PHP Hacker: "Hi, I'm the guy who made it so you can add items to an array > which > > is returned through __get()" > > PHP Fanboy: "Dude that is so awesome, how could I ever repay you!? Can I > buy > > you a beer?" > > I believe you can start buying drinks for Dmitry =)
Is that in 5.2.1? regards, Peter Send instant messages to your online friends http://au.messenger.yahoo.com

Antony Dovgal

19 years ago
On 02/19/2007 02:42 PM, Peter Hodge wrote:
> --- Antony Dovgal <antony@zend.com> wrote: >> I believe you can start buying drinks for Dmitry =) > > Is that in 5.2.1?
Yes.
-- Wbr, Antony Dovgal

Michael Wallner

19 years ago
Peter Hodge wrote:
> Hello, > > Does that fix the problem where: > > $object->theArray[] = (...); > > is invalid when 'theArray' is implemented using __get()?
No. It's about internal classes and information stored in C structures. Regards,
-- Michael