Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:56439 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 26042 invoked from network); 19 Nov 2011 23:51:24 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 19 Nov 2011 23:51:24 -0000 Authentication-Results: pb1.pair.com header.from=dragoonis@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dragoonis@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.170 as permitted sender) X-PHP-List-Original-Sender: dragoonis@gmail.com X-Host-Fingerprint: 209.85.220.170 mail-vx0-f170.google.com Received: from [209.85.220.170] ([209.85.220.170:41612] helo=mail-vx0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4E/A0-17754-BF048CE4 for ; Sat, 19 Nov 2011 18:51:23 -0500 Received: by vcbgb30 with SMTP id gb30so666656vcb.29 for ; Sat, 19 Nov 2011 15:51:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=EiWU3CKtqaToa8rZVktniSo6Ihrzzns637AnoCOziNY=; b=TE/f7ugHnIlIlPYCLP4DpmzEgojeCeuqsrnb4LdhDl6/iNaeJahGRdaQPAC8rcya0f c5906ItuhqhXStmI4/PIqp9fJxCb1IMuMHSh5PIf4WZaWe5HyrmCKRJz2H6IHir86dhH bHwfG27hQEOJeO8f4WMR8D63C8QaWIOjSFn3s= MIME-Version: 1.0 Received: by 10.224.39.81 with SMTP id f17mr3632063qae.63.1321746680569; Sat, 19 Nov 2011 15:51:20 -0800 (PST) Received: by 10.229.80.198 with HTTP; Sat, 19 Nov 2011 15:51:20 -0800 (PST) In-Reply-To: References: <9570D903A3BECE4092E924C2985CE485399328B6@MBX201.domain.local> Date: Sat, 19 Nov 2011 23:51:20 +0000 Message-ID: To: Yasuo Ohgaki Cc: Clint M Priest , "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: dragoonis@gmail.com (Paul Dragoonis) Link us to a http://gist.github.com paste please Yasou. Thanks. On Sat, Nov 19, 2011 at 9:45 PM, Yasuo Ohgaki wrote: > 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 = write >> protected property");}} >> class OrderLine{ =A0use Accessors; >> =A0private $r_property =3D array('price'=3D>1, 'amount'=3D>1); =A0privat= e >> $w_property =3D array('price'=3D>1, 'amount'=3D>1); >> =A0protected $price; =A0private $amount; >> =A0public function getTotal() { =A0 =A0return $this->price * $this->amou= nt; =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 TimePeri= od::$Milliseconds or possibly parent::$Milliseconds. >>> >>> Either of those methods (currently) tries to access a static property i= n the parent or defined class. =A0It would probably break existing code if = we tried to make the parent:: or TimePeriod:: syntax to access the parent a= ccessor. >>> >>> 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 >>> >> > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php >