Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:50697 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 56859 invoked from network); 29 Nov 2010 16:10:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 29 Nov 2010 16:10:38 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.42 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@gmail.com X-Host-Fingerprint: 209.85.212.42 mail-vw0-f42.google.com Received: from [209.85.212.42] ([209.85.212.42:40027] helo=mail-vw0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 88/62-42097-C70D3FC4 for ; Mon, 29 Nov 2010 11:10:38 -0500 Received: by vws11 with SMTP id 11so1249146vws.29 for ; Mon, 29 Nov 2010 08:10:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:reply-to :in-reply-to:references:from:date:message-id:subject:to:cc :content-type:content-transfer-encoding; bh=FgcAGLHe6Ud+YgT5fMyodUNGcQ2PviL9rjklIGD6U5Y=; b=wUK+4LUt0GFcdGcK9KCPnB1hlGBsVvX86YF3wx9lvpyR1nFAIwsY/CYoDqQwahjBpL 0iVeV+1KYRd7KX4cqN8eKeehcEQKsbm6HXR4KxJdMjRh7WH2bJm++TgK7T7DXKNI6izQ wsY4DeKTNU7SJ65Wbx9XN/nGBTvOT4zGwBQ3Y= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:reply-to:in-reply-to:references:from:date:message-id :subject:to:cc:content-type:content-transfer-encoding; b=icuvANQv5qz9q8AHcoVYRy74A9kMAc7ax0dk9muIO2doL/bNkIcEZRy+RGBkWsLIk+ SQKnVlk03ZjpGcsZ2u6ISpyImK/gSRRgdM3eY4w1H+6g4i48/uaYpUeIy5hyKLF1Cf5T tMuge9KnlWrPegAKsvDsQjiG5aWF41iO9jFWc= Received: by 10.229.238.197 with SMTP id kt5mr5133898qcb.25.1291047033969; Mon, 29 Nov 2010 08:10:33 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.100.130 with HTTP; Mon, 29 Nov 2010 08:10:13 -0800 (PST) Reply-To: RQuadling@googlemail.com In-Reply-To: <4CF3B903.6000204@gmail.com> References: <4CF3B903.6000204@gmail.com> Date: Mon, 29 Nov 2010 16:10:13 +0000 Message-ID: To: =?UTF-8?B?w4FuZ2VsIEdvbnrDoWxleg==?= Cc: internals@lists.php.net Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] RFC: C-sharp style property get/set syntax for PHP From: rquadling@gmail.com (Richard Quadling) 2010/11/29 =C3=81ngel Gonz=C3=A1lez : > Richard Quadling wrote: > setMilliseconds() should have $value as parameter instead of a magic name= . > > What about allowing this syntax to attach the property to a variable? > > For instance: > > class TimePeriod > { > =C2=A0 =C2=A0protected $seconds; > =C2=A0 =C2=A0protected $minutes; > =C2=A0 =C2=A0protected $hours; > > =C2=A0 =C2=A0public property Seconds read $seconds write setSeconds; > =C2=A0 =C2=A0public property Minutes read $seconds write setMinutes; > =C2=A0 =C2=A0public property Hours read $seconds write setHours; > > =C2=A0 =C2=A0public function setSeconds($seconds) > =C2=A0 =C2=A0{ > =C2=A0 =C2=A0 =C2=A0 =C2=A0if ($seconds >=3D 0 && $seconds < 60) $this->s= econds =3D $seconds; > =C2=A0 =C2=A0} > > =C2=A0 =C2=A0public function setMinutes($minutes) > =C2=A0 =C2=A0{ > =C2=A0 =C2=A0 =C2=A0 =C2=A0if ($minutes >=3D 0 && $minutes < 60) $this->m= inutes =3D $minutes; > =C2=A0 =C2=A0} > > =C2=A0 =C2=A0public function setHours($hours) > =C2=A0 =C2=A0{ > =C2=A0 =C2=A0 =C2=A0 =C2=A0if ($hours >=3D 0 && $hours < 24) $this->hours= =3D $hours; > =C2=A0 =C2=A0} > > } > > We only want to perform checks on write, so instead of writing the trivia= l > getters, the property is set to the variable itself. Child classes could > reattach it to a function if needing more control. Ouch. I messed up on the example code. Completely forget that there was a parameter to process... As for reading $seconds directly ... Well. If you think of the element that follows read as $this->xxxx, then if the parser can handle both ... read $seconds read getSeconds then yes for both. If not, then I'd guess that the getSeconds version should be the one we use as the value may not actually exist without some processing. Richard. --=20 Richard Quadling Twitter : EE : Zend @RQuadling : e-e.com/M_248814.html : bit.ly/9O8vFY