FAQ

michael.virnstein@brodos.de wrote:
Thanks! What would probably be a good thing, is to mention that in the docs
for the final keyword.

Make the constructor private and the class final. No instance will be
available,
and no inheritance possible. Methods has to work, and therefore they may
not
expect to have $this available in them.

Ok, will do, but this seems more like a hack to me, than an actual solution. ;)
i'd find it much more readable with the static keyword, but it's not my decision.

Regards, Michael
I think it is disputable whether is hack or not :) As you probably know Singleton
uses the same trick by declaring the constructor private (or protected) and making
the __clone method also private so there is no way to clone the single instance
(it is interesting that I have seen many slides discussing Singleton but quite a
few mention that cloning of the object should be forbidden).

Regards,
Andrey

Search Discussions

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupphp-internals @
categoriesphp
postedSep 29, '04 at 10:32a
activeSep 29, '04 at 10:32a
posts1
users1
websitephp.net

1 user in discussion

Andrey Hristov: 1 post

People

Translate

site design / logo © 2022 Grokbase