Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:37505 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 49574 invoked from network); 6 May 2008 20:04:35 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 6 May 2008 20:04:35 -0000 Authentication-Results: pb1.pair.com header.from=lars@strojny.net; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=lars@strojny.net; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain strojny.net designates 78.46.69.2 as permitted sender) X-PHP-List-Original-Sender: lars@strojny.net X-Host-Fingerprint: 78.46.69.2 milch.schokokeks.org Received: from [78.46.69.2] ([78.46.69.2:43239] helo=milch.schokokeks.org) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id DA/78-03521-1D9B0284 for ; Tue, 06 May 2008 16:04:35 -0400 Received: from [192.168.0.100] (xdsl-87-78-210-248.netcologne.de [::ffff:87.78.210.248]) (AUTH: PLAIN lars@schokokeks.org, SSL: TLSv1/SSLv3,256bits,CAMELLIA256-SHA) by milch.schokokeks.org with esmtp; Tue, 06 May 2008 22:04:30 +0200 id 000000000000C07B.000000004820B9CE.00006E7F To: internals Mailing List Cc: Marcus Boerger In-Reply-To: <489751132.20080506214551@marcus-boerger.de> 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> Date: Tue, 06 May 2008 22:04:29 +0200 Message-ID: <1210104269.3952.15.camel@localhost> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="=_milch.schokokeks.org-28287-1210104270-0001-2" X-Mailer: Evolution 2.22.0 Subject: Re: [PHP-DEV] Class Properties in Interfaces? From: lars@strojny.net (Lars Strojny) --=_milch.schokokeks.org-28287-1210104270-0001-2 Content-Type: text/plain Content-Transfer-Encoding: quoted-printable 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.=20 [...] >=20 > 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 tha= t > 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?=20 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 --=_milch.schokokeks.org-28287-1210104270-0001-2 Content-Type: application/pgp-signature; name="signature.asc" Content-Transfer-Encoding: 7bit Content-Description: Dies ist ein digital signierter Nachrichtenteil -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (GNU/Linux) iQIcBAABAgAGBQJIILnNAAoJECQPF+sCY6wHauwQAIQQwFKw2li7ejL0T0O28tpb hDMTfPCItT8FdSK5OexlVEqfN8CpDEKvP4PW6HHK0UniBRdvFWZAGp6SbGhgf4EA N5P9i/KfOKw7wHpYu0MsYjrRJw+yYtZue8D/Qt8+Svma2861lVLNTyk+sJajLOFp a4WcNEAYZJSJUDfwJNDmirCdhE3tssvqegA7Xa4rIBytjnChfaAS+cL7DcOJdVn8 Km0cHRh5mD4WW1TazirqBreCe/Y5zagmGxgUnRuQhMSSRkY1YkPeyCyHHp16X0dS nS0dplSK8zjz8errhNE+eUtoLHU5m74N2hTfT+F+sm1UkaLF7g8IC1S9fn8pDl5p m3SmUAt910ErvdjZ4TIXa0AA2QOov1q2nFht15OVBnzpgjsuz2adH0vvXJx34E1d wNC6GUqhQhHmZtLy1+cYDIGnHno6duUinLx8iN23UgmjkfNtJaBO2357QyIefzMA Ro/VpqczHJ5kYJ/4VtuDbSImpM9tQPdT9gmB6Xvyewq82P44a8+OVRPgMJoKa2kd b/Ndc/ngSh/zeudTQUqluN2DRKUxze4UOOh7poKR4mFdPlYzDNwbqlGZP/PJd9I4 NftJzkudikQMCY4LMUDHzhIV7aN4AnYMCFfD+q7VXUdk46m3pBb0bImfcjMFJ8YS WJjo+6MSEOsAnSTr1BmL =r/OZ -----END PGP SIGNATURE----- --=_milch.schokokeks.org-28287-1210104270-0001-2--