__invoke() weirdness

From: Date: Tue, 23 Dec 2008 16:02:43 +0000
Subject: __invoke() weirdness
Groups: php.internals 
Request: Send a blank email to internals+get-42368@lists.php.net to get a copy of this message
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

« previous php.internals (#42368) next »