Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:64488 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 37421 invoked from network); 2 Jan 2013 22:18:38 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 2 Jan 2013 22:18:38 -0000 Authentication-Results: pb1.pair.com header.from=steve@mrclay.org; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=steve@mrclay.org; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain mrclay.org from 50.22.11.19 cause and error) X-PHP-List-Original-Sender: steve@mrclay.org X-Host-Fingerprint: 50.22.11.19 bedford.accountservergroup.com Linux 2.6 Received: from [50.22.11.19] ([50.22.11.19:46805] helo=bedford.accountservergroup.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4E/00-35624-D32B4E05 for ; Wed, 02 Jan 2013 17:18:37 -0500 Received: from n128-227-2-2.xlate.ufl.edu ([128.227.2.2]:64948 helo=Distance-Ed-Sclay.local) by bedford.accountservergroup.com with esmtpsa (TLSv1:DHE-RSA-AES256-SHA:256) (Exim 4.80) (envelope-from ) id 1TqWds-0004tn-Lr; Wed, 02 Jan 2013 16:18:32 -0600 Message-ID: <50E4B232.5000505@mrclay.org> Date: Wed, 02 Jan 2013 17:18:26 -0500 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Clint Priest , PHP Internals References: <50E41BB6.4030901@zerocue.com> <50E4A43E.6030302@zerocue.com> In-Reply-To: <50E4A43E.6030302@zerocue.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bedford.accountservergroup.com X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - mrclay.org Subject: Re: [PHP-DEV] [PHP-RFC] Property Accessors 1.2 for Final Review before Vote From: steve@mrclay.org (Steve Clay) On 1/2/13 4:18 PM, Clint Priest wrote: > Omitting isset/unset has the same effect as declaring it without a body. This is > described in the RFC under Automatic Implementations with this line: > > Note that isset/unset implementations will always be provided if they are not defined or > if they are explicitly auto-defined (as above). I think the RFC could make this clearer: "isset & unset are always provided with the default implementations unless the author provides his/her own." Looking closer at the default implementations of isset/unset, I'm worried these could lead to confusion. Consider this code: class TimePeriod { private $Seconds = 3600; public $Hours { get { return $this->Seconds / 3600; } set { $this->Seconds = $value; } } } The RFC's default implementation is always bound to the shadow property, so here's what you really get: class TimePeriod { private $Seconds = 3600; public $Hours { get { return $this->Seconds / 3600; } set { $this->Seconds = $value; } // auto-generated isset { return $this->Hours != NULL; } unset { $this->Hours = NULL; } } } Note the resulting behavior: $t = new TimePeriod; $t->Hours; // 1 isset($t->Hours); // false !? unset($t->Hours); $t->Hours; // still 1 Effectively, authors who don't base their getters/setters on the shadowed property must be urged to create their own isset/unset because the default ones would be useless. I'm not crazy about this. I'd prefer these default implementations: isset { return $this->__getHours() != NULL; } unset { $this->__setHours(NULL); } $t = new TimePeriod; $t->Hours; // 1 isset($t->Hours); // true unset($t->Hours); $t->Hours; // null isset($t->Hours); // false Note these also work as expected when using the default get/set implementations. Of, course, my implementations don't actually *work* because you can't call an accessor from an accessor... Steve Clay -- http://www.mrclay.org/