Re: Bug in 5.3 __invoke() magic method?
| From: | Nathan Nobbe | Date: | Wed, 29 Sep 2010 21:29:06 +0000 |
| Subject: | Re: Bug in 5.3 __invoke() magic method? | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-49803@lists.php.net to get a copy of this message | ||
On Wed, Sep 29, 2010 at 2:56 PM, Stas Malyshev <smalyshev@sugarcrm.com>wrote:
> Hi!
>
>
> public function __construct()
>> {
>> $this->a = new A();
>> $this->a();
>>
>
> Here you are calling method a() of object $this. Such method does not
> exist. No bug here. Methods are properties are different things.
Stas, thanks for this. Seems that w/ __invoke() in 5.3 if a method property
is_callable then the engine should check for that and call it. I realize
the problem now though, in php instance variables can have the same
identifier as instance methods therefore collisions could exist, for example
class B
{
function __invoke() {}
}
class A
{
public $c = null;
function c() {}
}
$a = new A();
$a->c = new B();
$a->c();
seems i got the notion this would work from javascript, however i also
realize the reason it works there, only a single identifier is allowed which
would map to either a scalar or a function object and in the later case
would be invokable.
the implementation in php make sense to me now.
thanks for your time,
-nathan