Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88417 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 76465 invoked from network); 22 Sep 2015 18:48:25 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Sep 2015 18:48:25 -0000 Authentication-Results: pb1.pair.com header.from=bobwei9@hotmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=bobwei9@hotmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hotmail.com designates 65.55.111.154 as permitted sender) X-PHP-List-Original-Sender: bobwei9@hotmail.com X-Host-Fingerprint: 65.55.111.154 blu004-omc4s15.hotmail.com Received: from [65.55.111.154] ([65.55.111.154:65019] helo=BLU004-OMC4S15.hotmail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DC/01-00408-9EC91065 for ; Tue, 22 Sep 2015 14:24:42 -0400 Received: from BLU436-SMTP119 ([65.55.111.135]) by BLU004-OMC4S15.hotmail.com over TLS secured channel with Microsoft SMTPSVC(7.5.7601.23008); Tue, 22 Sep 2015 11:24:38 -0700 X-TMN: [+wX8OaVo1YTUCJi02n7PdGh4f3o5t3On] X-Originating-Email: [bobwei9@hotmail.com] Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_F137B1EB-96F5-44A9-BB17-2B22B2160C42" MIME-Version: 1.0 (Mac OS X Mail 8.2 \(2104\)) In-Reply-To: Date: Tue, 22 Sep 2015 20:24:33 +0200 CC: Joe Watkins , PHP internals References: To: Dmitry Stogov X-Mailer: Apple Mail (2.2104) X-OriginalArrivalTime: 22 Sep 2015 18:24:35.0501 (UTC) FILETIME=[EF0E65D0:01D0F563] Subject: Re: [PHP-DEV] [RFC] [VOTE] Short Closures From: bobwei9@hotmail.com (Bob Weinand) --Apple-Mail=_F137B1EB-96F5-44A9-BB17-2B22B2160C42 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" > Am 22.09.2015 um 20:05 schrieb Dmitry Stogov : >=20 > The current PHP version emits two warning on similar constructs, and = this > is explainable because we explicitly "use" $y. >=20 > $ sapi/cli/php -r 'function foo(){(function($x) use ($y){$y=3D3; = return > $y+$x;})(5);return $y;} var_dump(foo());' > PHP Notice: Undefined variable: y in Command line code on line 1 >=20 > PHP Notice: Undefined variable: y in Command line code on line 1 >=20 > NULL >=20 > Thanks. Dmitry. Well, yes. But that obviously needs alternate handling here as we don't = have full analysis to look at whether we'd need to import or not. Hence = we just are importing everything if it's used in Closure scope and = defined in parent scope. Because we obviously don't want this to emit a notice: function foo() { return ($x ~> { $y =3D 2; return $x + $y; })(10); } Else it'd be totally impossible to define any variables... Also, the long form sets $y to NULL in the Closure (we just have two = notices there because you return $y; too=E2=80=A6 if you remove that, = you'll be left with just one notice. Bob= --Apple-Mail=_F137B1EB-96F5-44A9-BB17-2B22B2160C42--