Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:89225 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 46626 invoked from network); 16 Nov 2015 09:30:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Nov 2015 09:30:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=t.carnage@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=t.carnage@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.51 as permitted sender) X-PHP-List-Original-Sender: t.carnage@gmail.com X-Host-Fingerprint: 74.125.82.51 mail-wm0-f51.google.com Received: from [74.125.82.51] ([74.125.82.51:34764] helo=mail-wm0-f51.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 8A/33-14654-812A9465 for ; Mon, 16 Nov 2015 04:30:01 -0500 Received: by wmvv187 with SMTP id v187so166094062wmv.1 for ; Mon, 16 Nov 2015 01:29:57 -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=RnRkUDN9iH7Vxqp6gi6fYBRVLN/22d6W9jjGoWAUT1o=; b=uiWb1nXsC+BBD4SVc6aT68Y5F/FuIcKTFV26iZ4kGcWyd5ioHvh+g4DP/1Sp3LfQLs hW3DnfbMd8lhE7a980DySOekDqKONhgzEBiKa2YTtbuKLyPjXWPhvUYb4kWqwBkXjdWB tR5tXpjsRgeViUdoi8L+/kB8/w0mfZ44eihPaYJqhgdSLFqubQNcVAc+DBkcuIZhMrp1 mO0OJWV0ufiFqwF+TkIfhxtozHSWU/kMDYGTYORA9yZquHXGQLce6NXb3/e4ksNfnxws sU2Evb8koyZPb57AGx3ng0R50ok+FbNClcUlLTLYkcJCSGKA/rlIKrIQMx8cuHI0+Bsd +IKg== MIME-Version: 1.0 X-Received: by 10.194.109.2 with SMTP id ho2mr29836167wjb.40.1447666197426; Mon, 16 Nov 2015 01:29:57 -0800 (PST) Received: by 10.27.130.149 with HTTP; Mon, 16 Nov 2015 01:29:57 -0800 (PST) In-Reply-To: References: Date: Mon, 16 Nov 2015 09:29:57 +0000 Message-ID: To: Daniel Persson Cc: PHP internals Content-Type: multipart/alternative; boundary=089e010d84e8737a140524a50d0f Subject: Re: [PHP-DEV] Immutable modifier From: t.carnage@gmail.com (Chris Riley) --089e010d84e8737a140524a50d0f Content-Type: text/plain; charset=UTF-8 On 16 November 2015 at 09:24, Daniel Persson wrote: > Any differance from the final keyword? > > http://php.net/manual/en/language.oop5.final.php > > On Mon, Nov 16, 2015 at 10:15 AM, Chris Riley wrote: > >> Hi, >> >> There has been a lot of interest recently (eg psr-7) in immutable data. >> I'm >> considering putting an RFC together to add language support for >> immutables: >> >> immutable class Foo { >> public $bar; >> public function __construct($bar) { >> $this->bar = $bar; >> } >> } >> >> Immutable on a class declaration makes all (maybe only public?) properties >> of the class immutable after construct; assigning to a property would >> result in a Fatal error. >> >> class Foo { >> public $bar; >> immutable public $baz; >> } >> >> Immutable on a property makes the property immutable once it takes on a >> none null value. Attempts to modify the property after this results in a >> fatal error. >> >> Any thoughts? >> ~C >> > > Yes, final prevents child classes from overriding a method or from extending a class entirely, this is a compile time constraint. Immutable prevents data modifications and as such is a run time constraint. ~C --089e010d84e8737a140524a50d0f--