Re: package-private classes?

From: Date: Sun, 30 Sep 2007 12:41:52 +0000
Subject: Re: package-private classes?
References: 1 2 3  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-48201@lists.php.net to get a copy of this message
On 2007 09 29 07:19, David Coallier wrote:
On 9/28/07, Joe Stump <joe@joestump.net> wrote:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I don't think there's any way to enforce it.
I didn't think so. Just asking.
I would suggest that we deal with it the same way we dealt with private methods in PHP4: if it's "@access private", it can be changed without a BC break
No arguments here. Just pondering :) - --Joe -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.5 (Darwin) iD8DBQFG/Yjyh0MUGpYY9OQRAuGRAKCg22mJ+KQnkm5RyYlYLeaII2EoKgCgrVcB ZlV5J9BKXxlpASflPnQHDMs= =ZxbZ -----END PGP SIGNATURE----- -- PEAR Development Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
I have asked about that particular problem and spoke to a few internals about that and most don't seem to want that in PHP. We are still at that level: Introduce concept of "strict classes" that do not permit dynamic property creation
Despite the problems it brings, dynamic properties in a class is well within "strict" PHP and can even be a very useful feature when used properly. I think the number of cases where it should be used is relatively small though. I would have been nice if you had to say "mutable class X" in order to acquire dynamic properties. However it's possible to simulate "immutable classes" (at runtime) by adding __get() and __set() methods that throw an exception. This is one of the most effective anti-typo debugging tricks I know of.

« previous php.pear.dev (#48201) next »