Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37504 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 45606 invoked from network); 6 May 2008 19:45:58 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 May 2008 19:45:58 -0000 Authentication-Results: pb1.pair.com header.from=helly@php.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=helly@php.net; spf=unknown; sender-id=unknown Received-SPF: unknown (pb1.pair.com: domain php.net does not designate 85.214.94.56 as permitted sender) X-PHP-List-Original-Sender: helly@php.net X-Host-Fingerprint: 85.214.94.56 aixcept.net Linux 2.6 Received: from [85.214.94.56] ([85.214.94.56:42664] helo=h1149922.serverkompetenz.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/B7-03521-375B0284 for ; Tue, 06 May 2008 15:45:58 -0400 Received: from dhcp-172-28-202-226.zrh.corp.google.com (unknown [193.142.125.1]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by h1149922.serverkompetenz.net (Postfix) with ESMTP id E5DF911F0DA; Tue, 6 May 2008 21:45:50 +0200 (CEST) Date: Tue, 6 May 2008 21:45:51 +0200 Reply-To: Marcus Boerger X-Priority: 3 (Normal) Message-ID: <489751132.20080506214551@marcus-boerger.de> To: Lars Strojny CC: Jeff Moore , "John Carter -X (johncart - PolicyApp Ltd at Cisco)" , Derick Rethans , In-Reply-To: <1210101672.3952.4.camel@localhost> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Class Properties in Interfaces? From: helly@php.net (Marcus Boerger) Hello Lars, Tuesday, May 6, 2008, 9:21:12 PM, you wrote: > Hi Marcus, et al., > Am Dienstag, den 06.05.2008, 09:09 -0700 schrieb Jeff Moore: > [...] >> I think this is really specifying implementation details in an >> interface: > I agree. > [...] >> This looks to me like the best way to handle this in interfaces: >> >> > interface Coord { >> > abstract $coord; >> > } > I think this is too unspecific. At least the visibility, setter and/or > getter and type-hint (assuming we will have type hints) should be > defined. Otherwise defining properties in interfaces become useless as > it does not tell somebody more except "there is a property". > interface Something > { > public $property { > string public function get(); > string protected function set(string $value); > } > } All fine with me. However we *would* need to specify which function is getter, setter, isset or unset. We need to avoid introducing new keywords, so I hope __get and so on in the hope that it would help in that direction. Also note that we do not need to define anything inside the property or we could choose to exactly do everything there. public $property { string public function __get() { return $this->_property; } string protected function __set(string $value) {...} } vs: public $property { __get = getProperty; __set = setProperty; } string public function getProperty() { return $this->_property; } string protected function setProperty(string $value) {} The advantage of keeping everything inside the property definition is that there is no need at all for any new keyword. And the handlers cannot get separated. The disadvantage is that the functions are always named __get and so on for all properties, so PHP would need to do an internal renaming. Which means we probably would not be able to call the functions manually. That larger handlers could clutter the code doesn't appear to be a disadvantage for me as it can easily be avoided if the handler just forwards the call. The next question I have now is what to do when people want direct access to the underlying value? 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))? Best regards, Marcus