Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:53206 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 55042 invoked from network); 8 Jun 2011 11:58:12 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Jun 2011 11:58:12 -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.210.42 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.210.42 mail-pz0-f42.google.com Received: from [209.85.210.42] ([209.85.210.42:42363] helo=mail-pz0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8C/F0-48516-3D36FED4 for ; Wed, 08 Jun 2011 07:58:12 -0400 Received: by pzk37 with SMTP id 37so219459pzk.29 for ; Wed, 08 Jun 2011 04:58:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=wdooE2P0ZQuq2JmxyN/KyKZjH3f5/z9tqP8tjmCqZN4=; b=FFVY1KMeDMqTG7G7aeihNZIkZAXajaeV0Ws5vFqVgbWspKQgUjN+75ZOxdzXfF9Kx6 fe+8Imndb8hDE2uKvzRN6uuexA75pb7EDLHM3YtR/Xnin+9AW1vV7Y2ZHPCgShLOUJhc mzt5S8QPR85LC1g0chv3Xraa35OSxLHQ0AQho= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; b=ZVp+t+r5s/IER0W9jkLQJukN2y942w7pUkKG8FKxuJDj0ZvFnkYT6CcOFrfNAXf8uH PbC3rZ1c8E4xbL7lkX75/UXyzk9WGTmOLmX3rdo45sAYf56wgbTL5JJ5yj/e6oscMowa gYqGCDgPrh18O2t2sjTZpom+NlMK4oFWlR6B4= Received: by 10.142.204.19 with SMTP id b19mr270998wfg.62.1307534289134; Wed, 08 Jun 2011 04:58:09 -0700 (PDT) MIME-Version: 1.0 Received: by 10.142.246.21 with HTTP; Wed, 8 Jun 2011 04:57:48 -0700 (PDT) In-Reply-To: <67f900ce904612afdba7650ccbed6ed4@mohiva.com> References: <67f900ce904612afdba7650ccbed6ed4@mohiva.com> Date: Wed, 8 Jun 2011 08:57:48 -0300 Message-ID: To: Christian Kaps Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=000e0cd32f30d5e37504a5320ca2 Subject: Re: [PHP-DEV] Re: $arr = array('Hello', 'world'); $arr(); From: felipensp@gmail.com (Felipe Pena) --000e0cd32f30d5e37504a5320ca2 Content-Type: text/plain; charset=UTF-8 Hi, 2011/6/8 Christian Kaps > Hi, > > > 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? >> >> > > what happens if I use this code. > > class Foo { > > public $bar; > > public function __construct() { > > $this->bar = array($this, 'baz'); > $this->bar(); > } > > public function bar() { > echo 'bar'; > } > > public function baz() { > echo 'baz'; > } > } > > new Foo(); > > What is the output of this snippet? > > Are there the same rules as for closures? > > Christian > > Yes, the same rules. -- Regards, Felipe Pena --000e0cd32f30d5e37504a5320ca2--