Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82567 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 531 invoked from network); 12 Feb 2015 23:06:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Feb 2015 23:06:52 -0000 Authentication-Results: pb1.pair.com header.from=tyra3l@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=tyra3l@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.176 as permitted sender) X-PHP-List-Original-Sender: tyra3l@gmail.com X-Host-Fingerprint: 74.125.82.176 mail-we0-f176.google.com Received: from [74.125.82.176] ([74.125.82.176:42937] helo=mail-we0-f176.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 29/14-15420-9023DD45 for ; Thu, 12 Feb 2015 18:06:50 -0500 Received: by mail-we0-f176.google.com with SMTP id x3so13235653wes.7 for ; Thu, 12 Feb 2015 15:06:46 -0800 (PST) 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=KWn6K33Chag3+szvtC9BRU4e7YXHWJuFsaTkdSGVAzo=; b=s5ksLsZO12oSKH3gEm2CIrFLv3pqaFmjv3uAmjCFevd+VaMxh1syD1QFlRQPELDzBf 8+XDkVVtX4p31Vw209dHpr5JZ4FJmcafytF5Ij1rqopJcnxvW+ZRLczBWojXcJ2XrFON Awn9evNP/qJNJ+QUv+PEPKQA7omuOTN1BJL1ozZeOQzeZLv/GHnpf9197iKL2HxPYy51 nV7wIpN+FIQXyK8XJ04nRzv9wI5ZuDQZzpT5tP5xIuLOHKUwsFOLdLQ4xZD9ocwNQyg5 JnHtMBQlmyHz0+kw+uyh4dXw0LYp2F2nxslIAwXU2rRHJxYOTYzgZSFM6v02Bxg9QTIr VQnw== MIME-Version: 1.0 X-Received: by 10.194.81.1 with SMTP id v1mr12270793wjx.50.1423782406078; Thu, 12 Feb 2015 15:06:46 -0800 (PST) Received: by 10.180.206.110 with HTTP; Thu, 12 Feb 2015 15:06:46 -0800 (PST) In-Reply-To: References: <54DCD8B7.40700@gmail.com> Date: Fri, 13 Feb 2015 00:06:46 +0100 Message-ID: To: Nikita Popov Cc: Rowan Collins , PHP internals Content-Type: multipart/alternative; boundary=047d7bb048768d46ad050eec2cc5 Subject: Re: [PHP-DEV] Remove $this from incompatible context From: tyra3l@gmail.com (Ferenc Kovacs) --047d7bb048768d46ad050eec2cc5 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On Thu, Feb 12, 2015 at 9:20 PM, Nikita Popov wrote: > On Thu, Feb 12, 2015 at 5:45 PM, Rowan Collins > wrote: > > > Nikita Popov wrote on 12/02/2015 14:24: > > > >> Hi internals, > >> > >> As part of [1] and [2] we have decided to remove support for doing > static > >> calls to instance methods, if this would result in an incompatible $th= is > >> variable to be used. When applying [3] this change we found that the > >> change > >> as originally intended may be too strict. > >> > > > > [snip] > > > > The compromise I'd like to implement instead is to only throw a fatal > >> error > >> if $this is actually used in the called method and otherwise throw a > >> deprecation warning. Calls from instance methods, static methods and > >> functions will all be handled the same. > >> > > > > [snip] > > > > I'm definitely in favour of this over completely forbidding such calls. > > > > The only thing I'd question is the use of E_DEPRECATED when the static > > call doesn't use $this. Is there actually any intent to change the > > behaviour in a future version? What is the advantage to doing so? It > > strikes me as rather like the case of "var" for properties, which had t= he > > deprecation notice removed. > > > > I think it would make more sense to raise an E_STRICT, since the main > > purpose seems to be to discourage users making such calls. > > > > The reason is that previously it was using E_DEPRECATED in some places an= d > E_STRICT in others. I'd like to have a consistent error level in all case= s, > so using E_DEPRECATED everywhere (I am not willing to downgrade existing > deprecations to strict warnings). > > And yes, I'm pretty sure there is intent to remove this completely in the > future - this is just another leftover from PHP 4. The approach outlined > here only avoids dropping support in PHP 7 already (which the original > patch did for all practical purposes). > > Nikita > adding the E_DEPRECATED was only about the assuming $this behavior: https://wiki.php.net/rfc/incompat_ctx so if we remove that behavior ($this is set to null) then I'm not sure why shouldn't we leave the calling non-static method as static as E_STRICT. are we planning to remove the ability to call non-static methods statically later on? that would be against the original proposal: "This proposal is not about removing static calls to instance methods or instance-like calls to static methods." and the original plan for removing this behavior was simply to remove/not assume $this: "Even though I think an error at call site would be the most useful to the user, the most sensible option is to just have $this =3D=3D=3D null inside = the callee, like when you do" I think the best course of action would be going with the original plan, null-ing out $this and keeping the calling a non static method statically as an E_STRICT. --=20 Ferenc Kov=C3=A1cs @Tyr43l - http://tyrael.hu --047d7bb048768d46ad050eec2cc5--