Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:52940 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 92769 invoked from network); 5 Jun 2011 15:53:09 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Jun 2011 15:53:09 -0000 Authentication-Results: pb1.pair.com smtp.mail=felipensp@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=felipensp@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.173 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: felipensp@gmail.com X-Host-Fingerprint: 209.85.212.173 mail-px0-f173.google.com Received: from [209.85.212.173] ([209.85.212.173:35547] helo=mail-px0-f173.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FE/DF-26000-466ABED4 for ; Sun, 05 Jun 2011 11:53:09 -0400 Received: by pxi16 with SMTP id 16so2011952pxi.18 for ; Sun, 05 Jun 2011 08:53:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:from:date:message-id:subject:to :content-type; bh=yyPN+gFQcqQEbsTJ0Y46UUlOOmhWGMVN8f45IndjA5c=; b=u3rQ2PnGzz3NjahmN4CaB60ta9YfP3YYBwWhJ74sOIoZGmFZfbJyxQtUK2ZiFl0/3T gFQiiWs1jLnuUoI5s4I7agW70v4aJSlPWZEFiZsMECb1ZHAqO5AlBk4e5/69uugWk7yA REfdI12A1ZwmVtl5tgybwaXm4RQ3vhPRMbRuE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:from:date:message-id:subject:to:content-type; b=J2s8jqy3chHdu9SAVqJ4i3ZWDG1MKtnQpQUVAj4i7YFBaYusFeDW9aK8ogZDmhwJQO MEF3AqXEXz/6O/xfeO1KRDdznldeaImtXJIZe7Q6si7sLd7vbt+VF2usQMznvL8ye0J2 lQVfBhzSmFWMWziNutkabXahLG3ctYanYitBY= Received: by 10.142.165.2 with SMTP id n2mr635360wfe.5.1307289185079; Sun, 05 Jun 2011 08:53:05 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.246.21 with HTTP; Sun, 5 Jun 2011 08:52:45 -0700 (PDT) Date: Sun, 5 Jun 2011 12:52:45 -0300 Message-ID: To: internals Content-Type: multipart/alternative; boundary=000e0cd2e3527ed19404a4f8fb24 Subject: $arr = array('Hello', 'world'); $arr(); From: felipensp@gmail.com (Felipe Pena) --000e0cd2e3527ed19404a4f8fb24 Content-Type: text/plain; charset=UTF-8 Hi all, Reading our bug tracker I noticed a good feature request [1] from 2009 which points to an interesting feature that I think makes sense for us, since we are now working with $f() using objects and strings, and the array('class', 'method') is an old known for call_user_func()-like functions. So, I wrote a patch [2] that allow such behavior to be consistent with arrays. See some examples: class Hello { public function world($x) { echo "Hello, $x\n"; return $this; } } $f = array('Hello','world'); var_dump($f('you')); $f = array(new Hello, 'foo'); $f(); All such calls match with the call_user_func() behavior related to magic methods, static & non-static methods. The array to be a valid callback should be a 2-element array, and it must be for the first element object/string and for the second string only. (just like our zend_is_callable() check and opcodes related to init call) Any thoughts? [1] - http://bugs.php.net/bug.php?id=47160 [2] - http://felipe.ath.cx/diff/fr47160.diff phpt: http://felipe.ath.cx/diff/fr47160.phpt -- Regards, Felipe Pena --000e0cd2e3527ed19404a4f8fb24--