Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37511 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32755 invoked from network); 7 May 2008 13:22:18 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 7 May 2008 13:22:18 -0000 Authentication-Results: pb1.pair.com smtp.mail=rquadling@googlemail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rquadling@googlemail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain googlemail.com designates 209.85.146.176 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rquadling@googlemail.com X-Host-Fingerprint: 209.85.146.176 wa-out-1112.google.com Received: from [209.85.146.176] ([209.85.146.176:41222] helo=wa-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DF/97-20715-80DA1284 for ; Wed, 07 May 2008 09:22:17 -0400 Received: by wa-out-1112.google.com with SMTP id v27so403583wah.17 for ; Wed, 07 May 2008 06:22:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=zkcGsnHCkIpDEky6DS8DLVskeEfJus2q+8+YooaoKo4=; b=hjWli7EnYdGGoeLBIIbLtRUVjaaYJ7FwE2K97JUXqbDeA6hXJATlupB0H21y0T2kQPidgaiDvlA4vZ3yqvqUZkAYSM3UE4nliE9DDNtAokStaZjmlZdsJtw1pZBFrujNLtjxvJWdAZ59+un+mZr+6r2q4bNgXJRvfeo6GydDT+Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=message-id:date:from:reply-to:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=CtiUrfYAfvbF/sD5e6+L4lBvrwm8c4iUPYg+AfsbvwZeercnGjUln8Mnwm0WWxQDhpfDqs3wxhnaI+WGJZQ3s0SZhQJ6LkZId+GTe+rtbxLAlkC2hpZnokdtSCUcVWwJMRM2uRGN6wDvPguHIdeBuOgcsX+BGggpDgrCRVZh9Ns= Received: by 10.114.89.1 with SMTP id m1mr1819537wab.193.1210166533747; Wed, 07 May 2008 06:22:13 -0700 (PDT) Received: by 10.114.209.15 with HTTP; Wed, 7 May 2008 06:22:13 -0700 (PDT) Message-ID: <10845a340805070622p78e1ca63r5290b03bfba182ed@mail.gmail.com> Date: Wed, 7 May 2008 14:22:13 +0100 Reply-To: RQuadling@GoogleMail.com To: "Lars Strojny" Cc: "internals Mailing List" , "Marcus Boerger" In-Reply-To: <1210104269.3952.15.camel@localhost> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <48169695.9040803@omegavortex.net> <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> <1210104269.3952.15.camel@localhost> Subject: Re: [PHP-DEV] Class Properties in Interfaces? From: rquadling@googlemail.com ("Richard Quadling") 2008/5/6 Lars Strojny : > Hi Marcus! > > Am Dienstag, den 06.05.2008, 21:45 +0200 schrieb Marcus Boerger: > [...] > > > All fine with me. However we *would* need to specify which function is > > getter, setter, isset or unset. > > [...] > > > > > public $property { > > string public function __get() { > > return $this->_property; > > } > > string protected function __set(string $value) {...} > > } > > That's the variant I prefer. It is pretty similar to the C# does it and > therefore follows the common PHP strategy of steeling everything > together ;) > > [...] > > > 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. > > Do you see any real use-case for calling them directly? > > > > 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. > > Either that or folding in the editor helps etc. pp. > > > > The next question I have now is what to do when people want direct access > > to the underlying value? > > I would think that accessing $this->property from __get()/__set() of the > property would address the value itself. Everything else would be > redirected to the accessors. > > > > 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))? > > Not sure about that. Forcing the user to define four accessors for a > property seems to be clutter but it would be - technically spoken - > correct. I don't have a fixed opinion here. > > cu, Lars > You would only normally need to define the four accessors if your property isn't a bog standard one or you didn't want to trigger any activity when a property changed. class foo { public $bar; } is fine. foo::bar is a completely normal property as we know it. -- ----- Richard Quadling Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731 "Standing on the shoulders of some very clever giants!"