Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:55755 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89283 invoked from network); 8 Oct 2011 17:22:30 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Oct 2011 17:22:30 -0000 Authentication-Results: pb1.pair.com smtp.mail=glopes@nebm.ist.utl.pt; spf=permerror; sender-id=unknown Authentication-Results: pb1.pair.com header.from=glopes@nebm.ist.utl.pt; sender-id=unknown Received-SPF: error (pb1.pair.com: domain nebm.ist.utl.pt from 193.136.128.22 cause and error) X-PHP-List-Original-Sender: glopes@nebm.ist.utl.pt X-Host-Fingerprint: 193.136.128.22 smtp2.ist.utl.pt Linux 2.6 Received: from [193.136.128.22] ([193.136.128.22:60567] helo=smtp2.ist.utl.pt) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id AF/22-13773-3D6809E4 for ; Sat, 08 Oct 2011 13:22:28 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 79F527000486 for ; Sat, 8 Oct 2011 18:22:24 +0100 (WEST) X-Virus-Scanned: by amavisd-new-2.6.4 (20090625) (Debian) at ist.utl.pt Received: from smtp2.ist.utl.pt ([127.0.0.1]) by localhost (smtp2.ist.utl.pt [127.0.0.1]) (amavisd-new, port 10025) with LMTP id A7Y1xuS6jSVn for ; Sat, 8 Oct 2011 18:22:24 +0100 (WEST) Received: from mail2.ist.utl.pt (mail.ist.utl.pt [IPv6:2001:690:2100:1::8]) by smtp2.ist.utl.pt (Postfix) with ESMTP id 3B03C70003E7 for ; Sat, 8 Oct 2011 18:22:24 +0100 (WEST) Received: from damnation (damnation-air.dulce.lo.geleia.net [IPv6:2001:470:94a2:2:222:fbff:fe79:e0f0]) (Authenticated sender: ist155741) by mail2.ist.utl.pt (Postfix) with ESMTPSA id 10FF32003A20 for ; Sat, 8 Oct 2011 18:22:22 +0100 (WEST) Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes To: internals@lists.php.net References: <4E5B24DD.10903@sugarcrm.com> <4E671355.5060908@sugarcrm.com> Date: Sat, 08 Oct 2011 18:22:18 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: Quoted-Printable Organization: =?utf-8?Q?N=C3=BAcleo_de_Eng=2E_Biom=C3=A9di?= =?utf-8?Q?ca_do_I=2ES=2ET=2E?= Message-ID: In-Reply-To: User-Agent: Opera Mail/11.51 (Linux) Subject: Re: [PHP-DEV] 5.4 beta From: glopes@nebm.ist.utl.pt ("Gustavo Lopes") On Sat, 08 Oct 2011 11:02:57 +0100, Fr=C3=A9d=C3=A9ric Hardy = wrote: > Hello ! > >> I don't think so, but if I had to summarize the innovations in 5.4, = >> this would be it: >> >> - Closures can now have an associated scope >> - Closures can now have a bound object >> - Closures can now be either static or non-static >> >> - Closures defined in a place with an active scope are scoped = >> accordingly >> - Closures defined inside an instance method (or bound closure) have = a = >> bound object (namely $this) >> - Closures are static if defined within a static method or with the = >> static keyword (static function() { ... }) > > Is it possible to have sample code about these ? > They will be very interesting to understand the RFC correctly and writ= e = > documentation or tutorial. > For example, i was tryed to use $this in a closure with PHP 5.B beta = > without any success :/, so if using $this in a closure is possible, i = = > would like to know how to do it.. > You can take a look at the tests. For instance, this patch has many: http://nebm.ist.utl.pt/~glopes/misc/closures_scope.patch For more, you can look at the SVN tree (Zend/tests/closure_*). In any case, here is a very simple example: foo; }; } } $a =3D new A; $c =3D $a->foo(); echo $c(); //echos "bar" -- = Gustavo Lopes