Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:61311 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 16028 invoked from network); 16 Jul 2012 15:25:16 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 Jul 2012 15:25:16 -0000 Authentication-Results: pb1.pair.com header.from=amaury.bouchard@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=amaury.bouchard@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.170 as permitted sender) X-PHP-List-Original-Sender: amaury.bouchard@gmail.com X-Host-Fingerprint: 209.85.161.170 mail-gg0-f170.google.com Received: from [209.85.161.170] ([209.85.161.170:53455] helo=mail-gg0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 67/51-09344-B5234005 for ; Mon, 16 Jul 2012 11:25:16 -0400 Received: by ggnf2 with SMTP id f2so6011997ggn.29 for ; Mon, 16 Jul 2012 08:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type; bh=Sf9WZgSOJUBOiNe1zDnMU5T3elsNDvxpPeKS17/lyx0=; b=ByAb0aFyl6XQ4EPD/tnZfFOaf/LvBDj4s7OXL52IsSeXsziAjiiu+PxkZBM3m1N57L gva0n+7yx4KhTI9PnPyx4i6zcSMfH7h37czbFcQQht/o20C66SScfZSnas5xrtk6iTsf g/SP10cIXpunaep8GyP3qQpraP/wUzbsi0cWaeFvzo0ywzhCSl+oh4PhWp3BxTDrKYZy zC1H3jsux+rXyRWWWOawYHI9/yDKf/G3zzZUIFByuT4z0+jU57cpsxUtTKdC6m9Ec3n/ mI2H4DW5wTZeJM4+N30bOTfs60a+eOgwvdTQ+ctRKNz3ofp10u4yHTzospUJ5BOY3W2/ pr6g== Received: by 10.60.12.37 with SMTP id v5mr16062275oeb.25.1342452312570; Mon, 16 Jul 2012 08:25:12 -0700 (PDT) MIME-Version: 1.0 Sender: amaury.bouchard@gmail.com Received: by 10.182.60.131 with HTTP; Mon, 16 Jul 2012 08:24:52 -0700 (PDT) In-Reply-To: References: Date: Mon, 16 Jul 2012 17:24:52 +0200 X-Google-Sender-Auth: Usgq6jUfgp0U_pyMxqEaaui1wzE Message-ID: To: Nikita Popov Cc: internals@lists.php.net Content-Type: multipart/alternative; boundary=e89a8f83a73537fcf004c4f40984 Subject: Re: [PHP-DEV] RFC Proposal - Attributes read/write visibility From: amaury@amaury.net (Amaury Bouchard) --e89a8f83a73537fcf004c4f40984 Content-Type: text/plain; charset=ISO-8859-1 2012/7/16 Nikita Popov > I'm not sure I really understand what this adds over the existing > getter/setter proposal. read-only and write-only should cover the most > common cases. If you do need visibility control, it is possible too: > > public $property { > get { ... } > protected set { ... } > } > > So what does this proposal add to it? > > Yes, but only if you have to write an accessor. If you just want an attribute that is: - readable from everywhere - writable from the current class only With my syntax: public:private $a; (read it aloud "public reading, private writing") With the existing RFC: public $a { private set { $this->a = $value; } } Which one is better? Why should I write code for that? If you read the existing RFC, you'll see that all examples involve a specific case: when you have a "fake" attribute, which manipulates date stored in other attributes. The given example is an $Hours attributes, which is calculated from the private $Seconds attribute. Again, it could be very useful. But it doesn't work all the time. --e89a8f83a73537fcf004c4f40984--