php-developer-list | 2002112
Date: 11/17/02
- Next message: Jani Taskinen: "Re: [PHP-DEV] [PATH] update to earlier proposed patch for getanyrr() function addition"
- Previous message: Marcus Börger: "Re: [PHP-DEV] [PATCH] php4/configure.in.patch & php4/ext/standard/dns_get_record.patch"
- In reply to: Stanislav Malyshev: "Re: [PHP-DEV] on the subject of overloading: __call()"
- Next in thread: Stanislav Malyshev: "Re: [PHP-DEV] on the subject of overloading: __call()"
- Reply: Stanislav Malyshev: "Re: [PHP-DEV] on the subject of overloading: __call()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Sun, 17 Nov 2002, Stanislav Malyshev wrote:
> BB>> related topic: in the current state of ze2, there are several ways to
> BB>> call methods directly that can't be emulated by call_user_func() -
> BB>> calling self::method() for instance, or the visibility of $this if
> BB>> you call class::method(). is that likely to stay true?
>
> Since __call is the method of the class, calling self::method can be
> achieved, I think. As for the second point - could you please explain
> furher what you mean, maybe with an example?
right, because static method calls don't get caught by __call, so you
always have $this.
the basic problem is that as it is now, if i do any of these
self::a_method($arg1,$arg2);
parent::a_method($arg1,$arg2);
some_other_class::a_method($arg1,$arg2);
inside of a class's method, $this is visible inside those called methods,
and points to the calling object.
but there is no way to make equivalent calls using call_user_func()
or call_user_func_array(). you can't use "parent::a_method",
array($this,'parent::a_method'), array(parent,"a_method"),
or array('parent',"a_method"). if you use the literal class name,
call_user_func_array(array(get_parent_class($this),'a_method'), $args);
it doesn't fail, but it's as if you were making a static method call
from outside of an object context - $this is not defined.
it's the last two cases - parent:: and some_other_class:: - that relate
to __call(), as you point out. and what truly matters is call_user_func_array(),
because not having it means you can't hand off the arguments from __call()'s
parameters to a method in the parent class or in some other class. not without
writing some pretty hacky eval() code, that is.
(btw, there should probably be a warning in the docs that methods that
are expecting to force their parameters to be references will not work
as expected when called by call_user_func_array().)
i'm attaching kind of long test case code & resulting output that
show what i mean.
- TEXT/PLAIN attachment: calltest.php
- TEXT/PLAIN attachment: calltest.out
-- PHP Development Mailing List <http://www.php.net/> To unsubscribe, visit: http://www.php.net/unsub.php
- Next message: Jani Taskinen: "Re: [PHP-DEV] [PATH] update to earlier proposed patch for getanyrr() function addition"
- Previous message: Marcus Börger: "Re: [PHP-DEV] [PATCH] php4/configure.in.patch & php4/ext/standard/dns_get_record.patch"
- In reply to: Stanislav Malyshev: "Re: [PHP-DEV] on the subject of overloading: __call()"
- Next in thread: Stanislav Malyshev: "Re: [PHP-DEV] on the subject of overloading: __call()"
- Reply: Stanislav Malyshev: "Re: [PHP-DEV] on the subject of overloading: __call()"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

