Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88871 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 38068 invoked from network); 19 Oct 2015 10:34:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Oct 2015 10:34:58 -0000 Authentication-Results: pb1.pair.com smtp.mail=lisachenko.it@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=lisachenko.it@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.178 as permitted sender) X-PHP-List-Original-Sender: lisachenko.it@gmail.com X-Host-Fingerprint: 209.85.217.178 mail-lb0-f178.google.com Received: from [209.85.217.178] ([209.85.217.178:36547] helo=mail-lb0-f178.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 02/04-07045-157C4265 for ; Mon, 19 Oct 2015 06:34:58 -0400 Received: by lbcao8 with SMTP id ao8so139511474lbc.3 for ; Mon, 19 Oct 2015 03:34:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=wwz3fy0RPWuFXBfULC6MrinTkRpWzhVnNdprBQ+Tfqo=; b=Y0CT7vJvVJjB9hFRSFaao7vaK/b2/za3yo4m3NzCRWa1AIyIt7sP051P8mHT3/hax4 MhKe0wzvFM73Pg/PFMuozD3ixOGMneVfmgTFlZPZ6lsX5LwO3zpGkHvl0TfegcvSC4uO cIRFjBJnag/+BRxVDLgERAPWa8JYoupAIjS9n08pNwAmqBH7fkhDzbgVv7pGqbgXzdKK lGa9JFIttb4NzftUwceDj7Dumx+g5vdu9s04Zi4EplPBLCD05IH6spbwR2RQwE74mzx7 jppThL8Kz5fc/uYP9z6atqouuTngztoPjBI92I+M5YkWt7sN+FX2XYt6LNhfN/A3aq5I Z4mw== MIME-Version: 1.0 X-Received: by 10.112.146.104 with SMTP id tb8mr14400529lbb.35.1445250893951; Mon, 19 Oct 2015 03:34:53 -0700 (PDT) Received: by 10.25.216.232 with HTTP; Mon, 19 Oct 2015 03:34:53 -0700 (PDT) In-Reply-To: References: <01f001d1052b$bed5cbb0$3c816310$@belski.net> <022301d1053b$06a91a50$13fb4ef0$@belski.net> <02c801d10588$9009fd80$b01df880$@belski.net> Date: Mon, 19 Oct 2015 13:34:53 +0300 Message-ID: To: Nikita Popov Cc: Anatol Belski , Xinchen Hui , Dmitry Stogov , PHP internals Content-Type: multipart/alternative; boundary=047d7b3a8bd0254bb8052272b2a2 Subject: Re: [PHP-DEV] Re: Forbid rebinding scope of closures created by ReflectionFunctionAbstract::getClosure() From: lisachenko.it@gmail.com (Alexander Lisachenko) --047d7b3a8bd0254bb8052272b2a2 Content-Type: text/plain; charset=UTF-8 2015-10-19 12:19 GMT+03:00 Nikita Popov : > This change is primarily targeting userland methods, so your use-case is > exactly the one this is supposed to prevent. Note that you can still use > ->bindTo($object). The only thing you cannot do is ->bindTo($object, > get_class($object)). It's very pity ( It was a very interesting feature that gives a birth for userland AOP, without it part of framework functionality *will be lost*. From the list of attached bugs I can see that all weird stuff happens only with internal classes/functions/methods. I never have seen a segfaults in my code that heavily uses closure rebinding with userland methods/classes and expect it to work in all future versions of PHP, starting from >=5.4. I don't know PHP engine well, but this feature with scope rebinding for methods allows some interesting patterns, like "Spy", "Field initializer", "Lazy proxy initializer", etc. We just take one method and bind it to another scope to perform an additional logic if needed. Maybe, apply your patch only to internal functions (restrict them to have $this inside) and simple functions? This will cover most bugs, but won't break an exisitng code. --047d7b3a8bd0254bb8052272b2a2--