Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88112 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 95319 invoked from network); 8 Sep 2015 01:23:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Sep 2015 01:23:53 -0000 Authentication-Results: pb1.pair.com header.from=derokorian@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=derokorian@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.180 as permitted sender) X-PHP-List-Original-Sender: derokorian@gmail.com X-Host-Fingerprint: 209.85.212.180 mail-wi0-f180.google.com Received: from [209.85.212.180] ([209.85.212.180:36122] helo=mail-wi0-f180.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E2/A5-34134-7A83EE55 for ; Mon, 07 Sep 2015 21:23:51 -0400 Received: by wicgb1 with SMTP id gb1so60205862wic.1 for ; Mon, 07 Sep 2015 18:23:48 -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=72n1V4Kh0UxvQQqmS+MxCoglte0ZVZ8jlgMJE572MZA=; b=jU3vU3mcM3DLwMXvHMLvcSX5bOVexLhH7D+X6a51fA7XKnE2N4j18sF9oU5xDi+Xrm XpruVHbtHFbgMDjoU9Y92VlmklSUDTkEE4jled6jyRfSBUWgrnJ3ucFi+VZBUGDdS2Ts 04llLFLVv1+ggF/t2ZmYyVfBDCI/GIra92GSlJDrBNUGqmh3pz15JAdw4Jwt1pRgJVF+ Q2pLx5Y4FzQdlZ5MAy8plO9cF37tyFHp7ylwjriP65A3yYbC40CFtNs4QoTEJ/vxTkoP vv1CYWB712wzeZ7nHfhG1PKHd0JUlo1gnJdzRHEKSvz+19NN7VU7WY29Vo8tutitogJh hx2Q== MIME-Version: 1.0 X-Received: by 10.194.89.5 with SMTP id bk5mr41957453wjb.144.1441675428655; Mon, 07 Sep 2015 18:23:48 -0700 (PDT) Received: by 10.28.183.130 with HTTP; Mon, 7 Sep 2015 18:23:48 -0700 (PDT) In-Reply-To: <7346C557-93DD-4E12-8E06-651D6A81A715@gmail.com> References: <20150827173432.GA71000@3006.local> <28.A5.59944.15C7CE55@pb1.pair.com> <55ED368C.5010209@gmail.com> <7346C557-93DD-4E12-8E06-651D6A81A715@gmail.com> Date: Mon, 7 Sep 2015 19:23:48 -0600 Message-ID: To: Xinchen Hui Cc: Andrea Faulds , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=089e010d8400ce78c1051f323785 Subject: Re: [PHP-DEV] Re: [RFC] [Concept] Class Constant visibility modifiersin PHP 7.1+ From: derokorian@gmail.com (Ryan Pallas) --089e010d8400ce78c1051f323785 Content-Type: text/plain; charset=UTF-8 On Mon, Sep 7, 2015 at 7:11 PM, Xinchen Hui wrote: > > > Sent from my iPhone > > > On Sep 8, 2015, at 02:09, Andrea Faulds wrote: > > > > Hi Stas, > > > > Stanislav Malyshev wrote: > >> > >> Private and protected methods and properties are private for a reason - > >> they may be radically changed or gone when the code is changing, and > >> thus external code should not rely on them, and the way to ensure it is > >> to deny that code access to them. However, I have hard time seeing how > >> that would apply to constants - they shouldn't really change, > > > > Why not? A constant's value doesn't change at runtime, but nothing stops > you changing the value in a new version. A real-world example for you: > phpng changed the values of the IS_* constants in the Zend Engine. > > > >> and if > >> they do, they either shouldn't be constant, or something in your world > >> changed fundamentally (i.e. scientists discovered that PI actually > >> equals to 4). > > > > Constants in code aren't necessarily natural constants. > > > > I wonder if you find in your code constant that you need > >> to hide because you foresee it changing - should it really be a constant > >> at all? > > > > If I have a value specified in the source code which will not change at > runtime, and which I don't want to expose as part of my public API... what > exactly do you propose it should be? I don't see why a constant isn't > fitting. > > > public static final as Java does > > https://3v4l.org/KX5jQ > PHP Fatal error: Cannot declare property Foo::$Bar final, the final modifier is allowed only for methods and classes in - on line 4 So there is no way to create an immutable property with a visibility modifier, unless you're suggesting that's what the RFC should be instead. --089e010d8400ce78c1051f323785--