Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:60273 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 87938 invoked from network); 24 Apr 2012 12:31:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 24 Apr 2012 12:31:22 -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.40 as permitted sender) X-PHP-List-Original-Sender: cpriest@zerocue.com X-Host-Fingerprint: 74.115.204.40 relay-hub204.domainlocalhost.com Received: from [74.115.204.40] ([74.115.204.40:8516] helo=relay-hub204.domainlocalhost.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id EF/69-34190-71D969F4 for ; Tue, 24 Apr 2012 08:31:21 -0400 Received: from MBX202.domain.local ([169.254.19.147]) by HUB204.domain.local ([192.168.69.4]) with mapi id 14.01.0355.002; Tue, 24 Apr 2012 08:31:16 -0400 To: "internals@lists.php.net" Thread-Topic: [PHP-DEV] RFC: Property get/set syntax (added isset/unset and references) Thread-Index: Ac0iFMmMOMpsT+bxSO2aogP0/HTvvQ== Date: Tue, 24 Apr 2012 12:31:16 +0000 Message-ID: <9570D903A3BECE4092E924C2985CE48555BEC3C2@MBX202.domain.local> 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: multipart/alternative; boundary="_000_9570D903A3BECE4092E924C2985CE48555BEC3C2MBX202domainloc_" MIME-Version: 1.0 Subject: [PHP-DEV] RFC: Property get/set syntax (added isset/unset and references) From: cpriest@zerocue.com (Clint M Priest) --_000_9570D903A3BECE4092E924C2985CE48555BEC3C2MBX202domainloc_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable I've updated the RFC to include details on adding isset/unset as well as re= ferences, detailed below: isset/unset: class TimePeriod { private $Seconds =3D 3600; public $Hours { get { return $this->Seconds / 3600; } set { $this->Seconds =3D $value; } isset { return !is_null($this->Seconds); } unset { $this->Seconds =3D NULL; } } } References: class SampleClass { private $_dataArray =3D array(1,2,5,3); public $dataArray { &get { return &$this->_dataArray; } } } $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 respectiv= e functions on the backing field. I could see only allowing isset/unset au= tomatic implementations if get/set were also specified as automatic impleme= ntations. Default implementations of isset/unset I'm also fielding comments/ideas on a way to always provide automatic imple= mentations of isset/unset for any accessor that didn't define one automatic= ally. One idea was for the isset (unspecified implementation) which would = return true if the getter provided any value which evaluated to true, such = as this: class TimePeriod { private $Seconds =3D 3600; public $Hours { get { return $this->Seconds / 3600; } set { $this->Seconds =3D $value; } } } /* Default Implementation Concept */ isset { return (int)$this->Hours; } unset { $this->Hours =3D NULL; } Note that the automatic implementation of unset is not strictly the same as= an unset() but without any sort of unset implementation a call to unset() = would do nothing. Alternatively we could throw an error to a call on isset= and/or unset against a property which didn't define an implementation. Thoughts? -Clint --_000_9570D903A3BECE4092E924C2985CE48555BEC3C2MBX202domainloc_--