Hello Diogo,

Sunday, August 31, 2008, 12:50:15 AM, you wrote:

> Exactly...

> Is that normal workings or more like a bugie one?

> On Sat, Aug 30, 2008 at 10:02 PM, Rasmus Lerdorf <[EMAIL PROTECTED]> wrote:
>> Cristian Rodríguez wrote:
>>>
>>> Diogo Neves escribió:
>>>>
>>>> Hi all,
>>>>
>>>> I'm emailling to ask why __call isn't called when you call a private
>>>> method from outside of function...
>>>
>>> Please provide example code ;-)
>>
>> He means this:
>>
>> class foo {
>>  private function bar() { }
>>  function __call($f,$a) {
>>    echo "called $f";
>>  }
>> }
>> $a = new foo;
>> $a->bar();
>>

In the above code you clearly try to call a private method. There is
nothing more to say. In the following case it coul dbe a bit different:

<?php
class foo {
  private function test() {
        echo __METHOD__ . "\n";
  }
}
class bar extends foo {
  function __call($name, $args) {
        echo __METHOD__ . "($name)\n";
  }
}
$obj = new foo;
$obj->test();
?>

This is different because we call into an object of type bar. Now in scope
bar we do not know anything about foo::test. That said we should probably
allow __call there rather than the error. And it is easy enought o fix as
we know that in bar we have only inherited foo::test.

If we move __call into foo it is the other way around then again. This is
because we will call into the object and start method resolution at scope
bar. As that does not know anything about test, we will use the inherited
method call to dynamically handle the call. However, that means we are in
scope foo where we do know about test and hence should issue the error.
But we will have a harder time issuing that error. As inside the engine we
actually never go down to scope foo and instead simply use the inherited
__call.

So yes, this can be seen as a bug and part of it can easily be fixed. But
I do not see an easy way to fix it 100% according to inheritance rules.

Best regards,
 Marcus


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to