Hello Lars, Wednesday, December 31, 2008, 6:59:08 PM, you wrote:
> Hi Markus, > have you measured the performance impact in a class with - say - ten > methods? And what to do with __get() and __call()? How are the > prioritized in the method resolve order? Translated into user code we now have: public function __zend_call($name, $args) { // Added property lookup if (isset($this->$name)) { // may call __isset $callable = $this->$name; // may call __get if (is_callable($callable)) { return call_user_func_array($callable, $args); } } // Original behavior: // Check for __call if (method_exists($this, '__call')) { return $this->__call($name, $args); } // error error_log('Function ' . __CLASS__ . '::' . $name . ' not found'); return NULL; } As to the performance impact. We add one additional hash-lookup per method call on a default class for a non found function. So whenever we would normally call __call we add an additional lookup. > cu, Lars > Am Mittwoch, den 31.12.2008, 17:38 +0100 schrieb Marcus Boerger: >> Hello David, >> >> Tuesday, December 23, 2008, 5:02:43 PM, you wrote: >> >> > Hi folks, >> >> > I played with __invoke today: >> >> > class Curry >> > { >> > protected $callable; >> > protected $args; >> >> > public static function create($callable) >> > { >> > $curry = new self($callable, array_slice(func_get_args(), 1)); >> > return $curry; >> > } >> >> > protected function __construct($callable, $args) >> > { >> > $this->callable = $callable; >> > $this->args = $args; >> > } >> >> > public function __invoke() >> > { >> > return call_user_func_array($this->callable, array_merge($this- >> >>args, func_get_args())); >> > } >> > } >> >> > However, it doesn't work consistently. >> >> > This works fine: >> > $d = new DateTime(); >> > $getAtom = Curry::create(array($d, 'format'), DATE_ATOM); >> > echo $getAtom(); >> >> > This gives a fatal "Call to undefined method DateTime::getAtom()" >> > $d = new DateTime(); >> > $d->getAtom = Curry::create(array($d, 'format'), DATE_ATOM); >> > echo $d->getAtom(); >> >> > Is that intentional? >> >> So far it is. Yet I as much as you do not like the inconsistency. So I >> spend a little bit on providing the following patch that should do what >> you were looking for. >> >> The disadvantage: Calling properties is case sensitive while calling >> methods isn't. But since this has nothign to do with this patch and the >> patch only increases consistency I am all for applying it. >> >> Comments? Lukas/Johannes? >> >> Oh I hate that case insensitivity.... and inconsistency.... >> >> > Cheers, >> >> > David >> >> >> >> >> >> Best regards, >> Marcus >> -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, >> visit: http://www.php.net/unsub.php Best regards, Marcus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php