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?

Cheers,

David


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

Reply via email to