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?

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

-- 
   Jabber: l...@strojny.net
   Weblog: http://usrportage.de

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil

Reply via email to