Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:88113 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 2640 invoked from network); 8 Sep 2015 02:15:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 8 Sep 2015 02:15:16 -0000 Authentication-Results: pb1.pair.com header.from=laruence@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=laruence@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.177 as permitted sender) X-PHP-List-Original-Sender: laruence@gmail.com X-Host-Fingerprint: 209.85.160.177 mail-yk0-f177.google.com Received: from [209.85.160.177] ([209.85.160.177:36460] helo=mail-yk0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id E4/16-34134-2B44EE55 for ; Mon, 07 Sep 2015 22:15:14 -0400 Received: by ykcf206 with SMTP id f206so98621797ykc.3 for ; Mon, 07 Sep 2015 19:15:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=EX1tDK6c94tZZBWhs1vTVX7NOYcgxoF09AQL259z4VA=; b=yokO29uCcecVzfr1AXgPqooI5Yf+6z7sdd2rm8G2K0qBx22EHxJLgnACRAQTNV0Kv0 eHmeCAA8+yzWUrnvyNk6aTBvqEq+AjQgiP1WY4OlAJc/QsU9BUyWBqXXX70dNmxUglh3 I5S1ESyVh0y03h5Y682gtZMnVv8GCyfOlk75knRGw8JPMf1yYvH5c7iCS2Vs/k6iWuYM 2ja2Maa5eruSsEAqfz05ZEwvqOJ0OxxHOluPOmLZdZZZnsFPoBHGx0Yua6GD7NH/tYhc Q9l4hDQIvF/SWPYxu+oHn0X8w5whtCztG1SqrcSzxEZuLsIfPYMZj+Z1h+CpzwJ5hm/n 3kjA== X-Received: by 10.129.58.10 with SMTP id h10mr20342718ywa.63.1441678511469; Mon, 07 Sep 2015 19:15:11 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.83.137 with HTTP; Mon, 7 Sep 2015 19:14:52 -0700 (PDT) In-Reply-To: References: <20150827173432.GA71000@3006.local> <28.A5.59944.15C7CE55@pb1.pair.com> <55ED368C.5010209@gmail.com> <7346C557-93DD-4E12-8E06-651D6A81A715@gmail.com> Date: Tue, 8 Sep 2015 10:14:52 +0800 Message-ID: To: Ryan Pallas Cc: Andrea Faulds , "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Re: [RFC] [Concept] Class Constant visibility modifiersin PHP 7.1+ From: laruence@gmail.com (Xinchen Hui) Hey: On Tue, Sep 8, 2015 at 9:23 AM, Ryan Pallas wrote: > > 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. Ah, I thought it should work , so sad.. thanks -- Xinchen Hui @Laruence http://www.laruence.com/