Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56438 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 12893 invoked from network); 19 Nov 2011 21:46:05 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2011 21:46:05 -0000 Authentication-Results: pb1.pair.com header.from=yohgaki@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=yohgaki@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.160.170 as permitted sender) X-PHP-List-Original-Sender: yohgaki@gmail.com X-Host-Fingerprint: 209.85.160.170 mail-gy0-f170.google.com Received: from [209.85.160.170] ([209.85.160.170:36659] helo=mail-gy0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 60/31-03486-D9328CE4 for ; Sat, 19 Nov 2011 16:46:05 -0500 Received: by ghrr20 with SMTP id r20so1966579ghr.29 for ; Sat, 19 Nov 2011 13:46:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:from:date :x-google-sender-auth:message-id:subject:to:cc:content-type :content-transfer-encoding; bh=j5tHbEBr3Xexar4fIVbXa8wERgxYmxm+IraAz/7twcA=; b=IwtR6ueAeDIqulFFalgYngrW3eSuOyT64Dse2GYMTLyOMxvMuD63kV2U4KsdS3OQoD oqK6c/Bnbe5pB3/cFptywpGhQG6QC2YTrYMgjgi6hl/up/fj19pCgO/+zfhOqpCT1wkK S2u0l5oO5XyvHHmFNqtJ2axMzWf1B20Tbfl2o= Received: by 10.236.180.101 with SMTP id i65mr12776992yhm.21.1321739162093; Sat, 19 Nov 2011 13:46:02 -0800 (PST) MIME-Version: 1.0 Sender: yohgaki@gmail.com Received: by 10.100.127.18 with HTTP; Sat, 19 Nov 2011 13:45:21 -0800 (PST) In-Reply-To: References: <9570D903A3BECE4092E924C2985CE485399328B6@MBX201.domain.local> Date: Sun, 20 Nov 2011 06:45:21 +0900 X-Google-Sender-Auth: 7UirCtpflsUzXqU1y5hFlBNgZds Message-ID: To: Clint M Priest Cc: "internals@lists.php.net" Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] Getters/Setters and parent getter/setter access From: yohgaki@ohgaki.net (Yasuo Ohgaki) It seems gmail broke newlines :( but you'll see the idea. -- Yasuo Ohgaki yohgaki@ohgaki.net 2011/11/20 Yasuo Ohgaki : > This is not a alternate syntax suggestion, but a currently working > solution (well partial) > > ($this->r_property[$name]) =A0 =A0 =A0return $this->$name; =A0 =A0else > trigger_error("Access to read protected property");} > public function __set($name, $value) { =A0if ($this->w_property[$name]) > =A0 $this->$name =3D $value; =A0else=A0 =A0 =A0trigger_error("Access to w= rite > protected property");}} > class OrderLine{ =A0use Accessors; > =A0private $r_property =3D array('price'=3D>1, 'amount'=3D>1); =A0private > $w_property =3D array('price'=3D>1, 'amount'=3D>1); > =A0protected $price; =A0private $amount; > =A0public function getTotal() { =A0 =A0return $this->price * $this->amoun= t; =A0}} > $line =3D new OrderLine; > $line->price =3D 20;$line->amount =3D 3; > echo "Total cost: ".$line->getTotal();?> > > You might would like to add as a current solution. > > -- > Yasuo Ohgaki > yohgaki@ohgaki.net > > > > 2011/11/19 Clint M Priest : >> The RFC here: https://wiki.php.net/rfc/propertygetsetsyntax >> >> Talks about allowing a sub-class to access a parent getter via TimePerio= d::$Milliseconds or possibly parent::$Milliseconds. >> >> Either of those methods (currently) tries to access a static property in= the parent or defined class. =A0It would probably break existing code if w= e tried to make the parent:: or TimePeriod:: syntax to access the parent ac= cessor. >> >> Anyone have any suggestions on an alternative syntax? >> >> I'm sure I could change it so that parent:: or TimePeriod:: from within = a getter/setter would cause it to access the parent getter/setter but that = would create an inconsistency within the language. >> >> Ideas? >> >> -Clint >> >