Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56882 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 74244 invoked from network); 12 Dec 2011 11:22:53 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 12 Dec 2011 11:22:53 -0000 Authentication-Results: pb1.pair.com smtp.mail=will.fitch@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=will.fitch@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.42 as permitted sender) X-PHP-List-Original-Sender: will.fitch@gmail.com X-Host-Fingerprint: 209.85.214.42 mail-bw0-f42.google.com Received: from [209.85.214.42] ([209.85.214.42:41739] helo=mail-bw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C0/70-06355-C04E5EE4 for ; Mon, 12 Dec 2011 06:22:52 -0500 Received: by bkbzx1 with SMTP id zx1so2617874bkb.29 for ; Mon, 12 Dec 2011 03:22:49 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=references:from:in-reply-to:mime-version:date:message-id:subject:to :cc:content-type; bh=YANCqI6E28OEHU8CWZPZ8/+tMZAUCpEqOHHvQ3Pi1bY=; b=EbQD23gvFXHpgFCT34XnVYPPSWcDaZxfs1kAQzzwz/yQtN0S4twyd41xxZCcS26U0C lircYXOTNkJjy0jU+NQCFfw1nSk28Fl7TtRaevJq42nAAkwlw1O2smS4Th9kUbbo12sI H6j31umjsAY1/2rWMIym/OhJDu9e+JPz1NLg4= Received: by 10.204.152.136 with SMTP id g8mr9322569bkw.127.1323688930411; Mon, 12 Dec 2011 03:22:10 -0800 (PST) References: <9570D903A3BECE4092E924C2985CE48539955BE3@MBX202.domain.local> In-Reply-To: <9570D903A3BECE4092E924C2985CE48539955BE3@MBX202.domain.local> Mime-Version: 1.0 (1.0) Date: Mon, 12 Dec 2011 06:22:09 -0500 Message-ID: <6980172827997547203@unknownmsgid> To: Clint M Priest Cc: "internals@lists.php.net" Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] Accessors v2.2 Patch From: will.fitch@gmail.com (Will Fitch) Clint, How about final public $Hours {} That would allow for the read only and limit the inheritance. Sent from my iPhone On Dec 11, 2011, at 11:02 PM, Clint M Priest wrote: > https://bugs.php.net/patch-display.php?bug=49526&patch=v2.2&revision=1323662103 > > This one addresses the read-only, write-only aspects. Though they are not quite what the RFC specifies... > > class TimePeriod { > public $Hours { > get { return 5; } > } > } > > $o = new TimePeriod(); > $o->Hours = 4; > > Results in: > Fatal error: Cannot set read-only property TimePeriod::$Hours, no setter defined. in %s on line %d > > Likewise in the other direction for write-only properties. > > The difficulty is that one could extend TimePeriod and define a setter. This is what the RFC talks about when using a readonly keyword. There presently isn't a readonly keyword defined, nor a writeonly. > > Should we create a readonly/writeonly keyword, or would something along these lines be better/more flexible? > > class TimePeriod { > public $Hours { > get { return 5; } > private final set { } > } > } > > Creating (forcing the author to create) a private final setter which would not allow a set to occur and could not be over-ridden? > > I've also added two tests for the read-only and write-only, as it exists in the above patch. > > Pierre, with the new/updated RFC, should I gut the sections that I decided against (such as the several alternate syntaxes) or leave them in? > > -Clint > >