Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37509 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 52255 invoked from network); 7 May 2008 06:38:43 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2008 06:38:43 -0000 Authentication-Results: pb1.pair.com header.from=jeff@procata.com; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=jeff@procata.com; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain procata.com from 207.58.169.145 cause and error) X-PHP-List-Original-Sender: jeff@procata.com X-Host-Fingerprint: 207.58.169.145 vps.procata.net Linux 2.5 (sometimes 2.4) (4) Received: from [207.58.169.145] ([207.58.169.145:36035] helo=vps.procata.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5B/E6-08231-27E41284 for ; Wed, 07 May 2008 02:38:43 -0400 Received: from adsl-63-201-158-210.dsl.snfc21.pacbell.net ([63.201.158.210] helo=[192.168.5.38]) by vps.procata.net with esmtp (Exim 4.68) (envelope-from ) id 1JtdII-00030D-SC; Wed, 07 May 2008 02:38:27 -0400 To: Marcus Boerger In-Reply-To: <489751132.20080506214551@marcus-boerger.de> X-Priority: 3 (Normal) References: <48169695.9040803@omegavortex.net> <339714303.20080429114607@marcus-boerger.de> <7dd2dc0b0804290817v3d8de030y1208a88f78c44411@mail.gmail.com> <862660524.20080506162159@marcus-boerger.de> <912CE6DE-22D0-43E6-BB6B-6154980050E5@procata.com> <1210101672.3952.4.camel@localhost> <489751132.20080506214551@marcus-boerger.de> Message-ID: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v919.2) Date: Tue, 6 May 2008 23:38:24 -0700 Cc: Lars Strojny , "John Carter -X (johncart - PolicyApp Ltd at Cisco)" , Derick Rethans , X-Mailer: Apple Mail (2.919.2) X-ACL-Warn: { X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vps.procata.net X-AntiAbuse: Original Domain - lists.php.net X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - procata.com X-Source: X-Source-Args: X-Source-Dir: Subject: Re: [PHP-DEV] Class Properties in Interfaces? From: jeff@procata.com (Jeff Moore) On May 6, 2008, at 12:45 PM, Marcus Boerger wrote: > public $property { > __get = getProperty; > __set = setProperty; > } > string public function getProperty() { > return $this->_property; > } > string protected function setProperty(string $value) {} Hi Marcus, I prefer this approach. One advantage is that it is compatible with existing classes that have done the getXXX() style accessors already. One thing That I am hoping to avoid, though, is the need to declare these kinds of basic accessor methods at all. (the ones that do nothing but set or read a backing property.) it seems like PHP should be able to generate them, or just fallback into a simple property access on the backing store, if that store is specified as part of the property. This should be the same as the previous example replacing setProperty and getProperty with direct references to the backing store: protected $_property; public $property { __get = $_property; __set = $_property; } > Or do we force people to always specify > get,set,isset und unset? Or should we only enforce get/set and have > isset > and unset emulated with them (isset()~>isset(get()), > unset()~>set(NULL))? it would be nice to have exactly this emulation for __isset and __unset when they are not declared. However, leaving out the __set should make the property read only and leaving out the __get should make the property write only (less useful, but symmetric). Following the C# convention for declaring properties in interfaces would declare the previous as interface bar { public $property {__set; __get;} } Best Regards, Jeff