Static classes in PHP via abstract keyword?

Posted by Boldewyn on Stack Overflow See other posts from Stack Overflow or by Boldewyn
Published on 2010-03-22T17:31:51Z Indexed on 2010/03/22 17:41 UTC
Read the original article Hit count: 271

Filed under:
|
|
|
|

According to the PHP manual, a class like this:

abstract class Example {}

cannot be instantiated. If I need a class without instance, e.g. for a registry pattern:

class Registry {}
// and later:
echo Registry::$someValue;

would it be considered good style to simply declare the class as abstract? If not, what are the advantages of hiding the constructor as protected method compared to an abstract class?

Rationale for asking: As far as I see it, it could a bit of feature abuse, since the manual refers to abstract classes more as like blueprints for later classes with instantiation possibility.

© Stack Overflow or respective owner

Related posts about best-practices

Related posts about php