Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:42368 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54471 invoked from network); 23 Dec 2008 16:02:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Dec 2008 16:02:47 -0000 Authentication-Results: pb1.pair.com smtp.mail=david.zuelke@bitextender.com; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=david.zuelke@bitextender.com; sender-id=unknown Received-SPF: error (pb1.pair.com: domain bitextender.com from 80.237.132.12 cause and error) X-PHP-List-Original-Sender: david.zuelke@bitextender.com X-Host-Fingerprint: 80.237.132.12 wp005.webpack.hosteurope.de Received: from [80.237.132.12] ([80.237.132.12:55669] helo=wp005.webpack.hosteurope.de) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FD/C3-33440-6AB01594 for ; Tue, 23 Dec 2008 11:02:47 -0500 Received: from munich.bitxtender.net ([85.183.90.3] helo=[10.224.254.2]); authenticated by wp005.webpack.hosteurope.de running ExIM using esmtpsa (TLSv1:RC4-SHA:128) id 1LF9iW-0004k1-3d; Tue, 23 Dec 2008 17:02:44 +0100 Message-ID: <08AA10DA-2704-415C-8A8C-893C89990DC1@bitextender.com> To: PHP Internals Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Date: Tue, 23 Dec 2008 17:02:43 +0100 X-Mailer: Apple Mail (2.930.3) X-bounce-key: webpack.hosteurope.de;david.zuelke@bitextender.com;1230048167;73c59d0c; Subject: __invoke() weirdness From: david.zuelke@bitextender.com (=?ISO-8859-1?Q?David_Z=FClke?=) 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