2009/1/6 David Coallier <dav...@php.net>:
>> call to __call() on private method invocation. The former approach presents
>> more of a BC
>> problem IMHO, so I am advocating the latter. I've attached a simple patch
>> for consideration.
>>
>
> I'd say go ahead, this sounds like common sense to be consistent in
> both methods and members.
>

Cool, looks like this has gone in already. A couple of comments:
1. I think the change has not been made for callbacks (so callbacks
now behave differently from normal method invocations).
2. Perhaps on 5_3 and HEAD, the equivalent change should be made for
__callStatic()?

Addressing those two points would make things even more consistent.
I'm adding some testcases to illustrate.


--TEST--
Trigger __call() in lieu of non visible methods when called via a callback.
--FILE--
<?php
class C {
        protected function prot() { }
        private function priv() { }
        public function __call($name, $args)    {
        echo "In __call() for method $name()\n";
    }
}

$c = new C;
call_user_func(array($c, 'none'));
call_user_func(array($c, 'prot'));
call_user_func(array($c, 'priv'));
?>
--EXPECTF--
In __call() for method none()
In __call() for method prot()
In __call() for method priv()



--TEST--
Trigger __callStatic() in lieu of non visible methods when called
directly or via a callback.
--FILE--
<?php
class C {
        protected static function prot() { }
        private static function priv() { }
        public static function __callStatic($name, $args)    {
        echo "In __callStatic() for method $name()\n";
    }
}

echo "Using direct method invocation:\n";
C::none();
C::prot();
C::priv();

echo "\nUsing callbacks:\n";
call_user_func(array('C', 'none'));
call_user_func(array('C', 'prot'));
call_user_func(array('C', 'priv'));
?>
--EXPECTF--
Using direct method invocation:
In __callStatic() for method none()
In __callStatic() for method prot()
In __callStatic() for method priv()

Using callbacks:
In __callStatic() for method none()
In __callStatic() for method prot()
In __callStatic() for method priv()

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

Reply via email to