Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60304 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 86580 invoked from network); 25 Apr 2012 00:12:47 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 25 Apr 2012 00:12:47 -0000 Authentication-Results: pb1.pair.com header.from=cpriest@zerocue.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=cpriest@zerocue.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zerocue.com designates 74.115.204.54 as permitted sender) X-PHP-List-Original-Sender: cpriest@zerocue.com X-Host-Fingerprint: 74.115.204.54 relay-hub202.domainlocalhost.com Received: from [74.115.204.54] ([74.115.204.54:35663] helo=relay-hub202.domainlocalhost.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 49/75-54790-971479F4 for ; Tue, 24 Apr 2012 20:12:43 -0400 Received: from MBX202.domain.local ([169.254.19.147]) by HUB202.domain.local ([192.168.69.2]) with mapi id 14.01.0355.002; Tue, 24 Apr 2012 20:12:39 -0400 To: Anthony Ferrara CC: "internals@lists.php.net" Thread-Topic: [PHP-DEV] RFC: Property get/set syntax (added isset/unset and references) Thread-Index: Ac0iFMmMOMpsT+bxSO2aogP0/HTvvQAPUf0AAAl0vqA= Date: Wed, 25 Apr 2012 00:12:38 +0000 Message-ID: <9570D903A3BECE4092E924C2985CE48555BED089@MBX202.domain.local> References: <9570D903A3BECE4092E924C2985CE48555BEC3C2@MBX202.domain.local> In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [192.168.64.23] Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: RE: [PHP-DEV] RFC: Property get/set syntax (added isset/unset and references) From: cpriest@zerocue.com (Clint Priest) That makes sense to me, a number (possibly all) of the errors I've added/mo= dified could be eligible for this. In those cases it would do "the next be= st thing," such as ignore a setter definition, etc. I may not have a perfe= ct understanding of what would leave the "engine in an unstable state howev= er" as Derick mentions on his post about E_RECOVERABLE_ERROR. =20 > -----Original Message----- > From: Anthony Ferrara [mailto:ircmaxell@gmail.com] > Sent: Tuesday, April 24, 2012 10:40 AM > To: Clint Priest > Cc: internals@lists.php.net > Subject: Re: [PHP-DEV] RFC: Property get/set syntax (added isset/unset an= d references) >=20 > Clint, >=20 > Additionally, one more comment related to the read-only and write-only. = I noticed that you're using E_ERROR for improper access. > Obviously you don't want this to be a warning, as the execution shouldn't= continue because that would be undefined. However, what > about setting it to E_RECOVERABLE_ERROR, so that it can be captured and r= ecovered from...? The engine wouldn't be in an unstable > state, so if we install an error_handler that throws an exception, there'= s no reason to force-terminate the application... >=20 > I guess I'm just adverse to using E_ERROR except for cases where it's lit= erally not safe to continue (usually because the engine is put in > an inconsistent state)... >=20 > Anthony >=20 > On Tue, Apr 24, 2012 at 8:31 AM, Clint M Priest wro= te: > > I've updated the RFC to include details on adding isset/unset as well a= s references, detailed below: > > > > isset/unset: > > > > class TimePeriod { > > =A0 =A0private $Seconds =3D 3600; > > > > =A0 =A0public $Hours { > > =A0 =A0 =A0 =A0get { return $this->Seconds / 3600; } > > =A0 =A0 =A0 =A0set { $this->Seconds =3D $value; } > > =A0 =A0 =A0 =A0isset { return !is_null($this->Seconds); } > > =A0 =A0 =A0 =A0unset { $this->Seconds =3D NULL; } > > =A0 =A0} > > } > > > > References: > > > > > > class SampleClass { > > > > =A0 =A0private $_dataArray =3D array(1,2,5,3); > > > > > > > > =A0 =A0public $dataArray { > > > > =A0 =A0 =A0 =A0&get { return &$this->_dataArray; } > > > > =A0 =A0} > > > > } > > > > > > > > $o =3D new SampleClass(); > > > > sort($o->dataArray); > > > > /* $o->dataArray =3D=3D array(1,2,3,5); */ > > > > Comments? > > > > These would also include automatic implementations which call the respe= ctive functions on the backing field. =A0I could see only > allowing isset/unset automatic implementations if get/set were also speci= fied as automatic implementations. > > > > Default implementations of isset/unset > > > > I'm also fielding comments/ideas on a way to always provide automatic i= mplementations of isset/unset for any accessor that didn't > define one automatically. =A0One idea was for the isset (unspecified impl= ementation) which would return true if the getter provided any > value which evaluated to true, such as this: > > > > class TimePeriod { > > =A0 =A0private $Seconds =3D 3600; > > > > =A0 =A0public $Hours { > > =A0 =A0 =A0 =A0get { return $this->Seconds / 3600; } > > =A0 =A0 =A0 =A0set { $this->Seconds =3D $value; } > > =A0 =A0} > > } > > /* Default Implementation Concept */ > > > > =A0 =A0 =A0 =A0isset { return (int)$this->Hours; } > > =A0 =A0 =A0 =A0unset { $this->Hours =3D NULL; } > > > > Note that the automatic implementation of unset is not strictly the sam= e as an unset() but without any sort of unset implementation > a call to unset() would do nothing. =A0Alternatively we could throw an er= ror to a call on isset and/or unset against a property which didn't > define an implementation. > > > > Thoughts? > > > > -Clint