Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92084 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87207 invoked from network); 4 Apr 2016 17:54:03 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 4 Apr 2016 17:54:03 -0000 Authentication-Results: pb1.pair.com header.from=michal@brzuchalski.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=michal@brzuchalski.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain brzuchalski.com designates 188.165.245.118 as permitted sender) X-PHP-List-Original-Sender: michal@brzuchalski.com X-Host-Fingerprint: 188.165.245.118 ns220893.ip-188-165-245.eu Received: from [188.165.245.118] ([188.165.245.118:42264] helo=poczta.brzuchalski.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 7F/12-29546-23AA2075 for ; Mon, 04 Apr 2016 13:53:57 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by poczta.brzuchalski.com (Postfix) with ESMTP id C4839298420D for ; Mon, 4 Apr 2016 19:53:50 +0200 (CEST) Received: from poczta.brzuchalski.com ([127.0.0.1]) by localhost (poczta.brzuchalski.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id TCgGHbJQF7AK for ; Mon, 4 Apr 2016 19:53:48 +0200 (CEST) Received: from mail-lf0-f53.google.com (unknown [209.85.215.53]) by poczta.brzuchalski.com (Postfix) with ESMTPSA id B4CF229841C4 for ; Mon, 4 Apr 2016 19:53:47 +0200 (CEST) Received: by mail-lf0-f53.google.com with SMTP id c62so182377198lfc.1 for ; Mon, 04 Apr 2016 10:53:47 -0700 (PDT) X-Gm-Message-State: AD7BkJJ6CFW+zbrYK3Q815XYNCbBQWNFlaXV7v2G10a2in2afOPr41jYZ0SflPGyydNfcpKAY2/oX7q6+9u4yg== MIME-Version: 1.0 X-Received: by 10.25.17.91 with SMTP id g88mr9049968lfi.38.1459792426621; Mon, 04 Apr 2016 10:53:46 -0700 (PDT) Received: by 10.25.24.40 with HTTP; Mon, 4 Apr 2016 10:53:46 -0700 (PDT) Date: Mon, 4 Apr 2016 19:53:46 +0200 X-Gmail-Original-Message-ID: Message-ID: To: internals@lists.php.net Content-Type: multipart/alternative; boundary=001a113f90f808e247052fac69e6 Subject: Final properties From: michal@brzuchalski.com (=?UTF-8?Q?Micha=C5=82_Brzuchalski?=) --001a113f90f808e247052fac69e6 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hey Internals, I'm new here. I've been wondering / working on adding final properties into PHP lang. This work started once I had the time to read the "Core Java for Impateient" by Cay S. Horstmann and found it very usefull to have final properties like Java. Those properties differ than `const` because they can be set at runtime - but only once in their lifetime. Such properties could be very usefull in Singletons, ValueObjects etc. impl like: class Money { public final $amount; public final $currency; public function __constructor($amount, $currency) { $this->amount =3D $amount; $this->currency =3D $currency; } } In above example there is even no need for getter because those properties are immutable through the final keyword, it means those properties cannot change their references just like in Java https://en.wikipedia.org/wiki/Final_(Java) I've already started some impl on own fork https://github.com/php/php-src/compare/master...brzuchal:final-properties I've got some basics in C programming, don't know yet if I can impl it complex. I was wondering if it is usefull in yours opinion or is it only my impression. I can provide an RFC if it sounds usefull and if I get Wiki karma Thanks -- Micha=C5=82 Brzuchalski (aka brzuchal) --001a113f90f808e247052fac69e6--