Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88419 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 82960 invoked from network); 22 Sep 2015 19:24:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Sep 2015 19:24:38 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.213.49 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.213.49 mail-vk0-f49.google.com Received: from [209.85.213.49] ([209.85.213.49:36331] helo=mail-vk0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id FB/42-00408-5FAA1065 for ; Tue, 22 Sep 2015 15:24:37 -0400 Received: by vkfp126 with SMTP id p126so13481909vkf.3 for ; Tue, 22 Sep 2015 12:24:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=N8d/V5QPwvg3iqVMzi5Ygd+p8BdNUW9NxE+/MrqsmOg=; b=I7JbbqGXmxO/sp8BW6Sw+O86M3paIHH15ysucf1Y6tJmuRN2KDe8/cmXaIYDivR3x/ P+m1wHWXDIMgYXETpbSpa3o0svUwqiGet7iQP6tZ6Il7UYwzsXXHmAwL27RszFaI5qMf imw78ceHt1i9LgUnrrdmO/4vHmpUSoYsGAdOHX0bjrIPwPGyfjxBIPFnrFNOUGH8emWU ys9R6BGGq0jVNOo4dZtus5jG8EKqc06Zfe7YG0PMxysrGFxv7EnSR7EKcJG2aLI6jU4B JKrsIcx6KG4CcVNd7nt5pKGIK97fRA5o8OL+xe8L9bLCIwqUoa85f/q1J924BzCXxUZT m6Sw== X-Gm-Message-State: ALoCoQkkFe+lPDy5EfduFnBls6BrIxYQv4l0TZ26omlQp8r82N0jlGR1b3/6gkFiiDJ8+ZJIUbJfdCyVlD5g692EPw9xcoA7YQVpsikOfHyZHqO1iqagZdeuTltJzFqHdlXLuM0awA/4vVOr1NXyRmExxnE1A31LuCLUgEQq42DfrthkDnjAQxQ= MIME-Version: 1.0 X-Received: by 10.31.54.194 with SMTP id d185mr19819520vka.131.1442949874831; Tue, 22 Sep 2015 12:24:34 -0700 (PDT) Received: by 10.103.24.5 with HTTP; Tue, 22 Sep 2015 12:24:34 -0700 (PDT) In-Reply-To: References: Date: Tue, 22 Sep 2015 22:24:34 +0300 Message-ID: To: Bob Weinand Cc: Joe Watkins , PHP internals Content-Type: multipart/alternative; boundary=001a11438b28b7fd0b05205af2b6 Subject: Re: [PHP-DEV] [RFC] [VOTE] Short Closures From: dmitry@zend.com (Dmitry Stogov) --001a11438b28b7fd0b05205af2b6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Tue, Sep 22, 2015 at 9:24 PM, Bob Weinand wrote: > > Am 22.09.2015 um 20:05 schrieb Dmitry Stogov : > > The current PHP version emits two warning on similar constructs, and this > is explainable because we explicitly "use" $y. > > $ 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 > > PHP Notice: Undefined variable: y in Command line code on line 1 > > NULL > > 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 w= e > just are importing everything if it's used in Closure scope and defined i= n > 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. > I saw, you have fixed that warning on implicit use. Thanks. Dmitry. > > Bob > --001a11438b28b7fd0b05205af2b6--