Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:78428 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 60991 invoked from network); 28 Oct 2014 14:12:52 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 28 Oct 2014 14:12:52 -0000 Authentication-Results: pb1.pair.com header.from=ajf@ajf.me; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ajf@ajf.me; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain ajf.me designates 192.64.116.216 as permitted sender) X-PHP-List-Original-Sender: ajf@ajf.me X-Host-Fingerprint: 192.64.116.216 imap10-3.ox.privateemail.com Received: from [192.64.116.216] ([192.64.116.216:38545] helo=imap10-3.ox.privateemail.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 45/36-21571-464AF445 for ; Tue, 28 Oct 2014 09:12:52 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.privateemail.com (Postfix) with ESMTP id 32B302400E9; Tue, 28 Oct 2014 10:12:50 -0400 (EDT) X-Virus-Scanned: Debian amavisd-new at imap10.ox.privateemail.com Received: from mail.privateemail.com ([127.0.0.1]) by localhost (imap10.ox.privateemail.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id rZ9ln6CEWXsc; Tue, 28 Oct 2014 10:12:50 -0400 (EDT) Received: from oa-res-26-28.wireless.abdn.ac.uk (oa-res-26-28.wireless.abdn.ac.uk [137.50.26.28]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.privateemail.com (Postfix) with ESMTPSA id 5C7742400D0; Tue, 28 Oct 2014 10:12:48 -0400 (EDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 8.0 \(1990.1\)) In-Reply-To: Date: Tue, 28 Oct 2014 14:12:47 +0000 Cc: Rowan Collins , "internals@lists.php.net" Content-Transfer-Encoding: quoted-printable Message-ID: <1B4C749F-7AD2-44A4-AEC3-C2781F14AE5E@ajf.me> References: <6E04B9BE-854E-4112-8C74-7D90BD8BFE95@ajf.me> <544D48A3.6070905@gmail.com> <572FEBD1-99A8-4788-83F9-D99E470FB16D@ajf.me> To: Chris Wright X-Mailer: Apple Mail (2.1990.1) Subject: Re: [PHP-DEV] [RFC] Readonly Properties From: ajf@ajf.me (Andrea Faulds) > On 28 Oct 2014, at 09:46, Chris Wright wrote: >=20 > Sorry, but I don't like this. This means that the visibility modifier = is no longer next to the thing that it applies to, I wouldn=E2=80=99t say that. The visibility modifier is an aspect of the = property itself, not its implementation. A property can be = public-readable and private-writeable regardless of whether it=E2=80=99s = a plain property or is a getter and a setter. > IMO this is actually harmful to the readability because the order in = which the accessors were defined then becomes significant It wouldn=E2=80=99t be significant. The public/private doesn=E2=80=99t = apply to the getters and setters, it applies to reading and writing from = the property, regardless of its implementation. If we did=E2=80=99t enforce order, got the read/write syntax and getters = and setters, hypothetically this would be possible: public/private $foobar { set($value) { =E2=80=A6 } get { =E2=80=A6 } } However, hopefully coding style guides would discourage that. > I would suggest something like this: >=20 > public $foobar { > get { return $this->bar * $this->foo; } > private set($value) { $this->bar =3D $value / $this->foo } > } >=20 > ...where only a single visibility modifier is permitted on the left, = and this is treated as the *default* visibility for the accessors, which = are free to declare another visibility if they want I don=E2=80=99t like this, it=E2=80=99s moving the visibility again and = having it split between the start and end of the declaration. -- Andrea Faulds http://ajf.me/