tags:

views:

40

answers:

1

I realize that it's possible to define a static class method as private and protected in PHP. This allows for an instantiated class, or public static method to access it's own private/protected static methods.

protected static function jumpOver  ()

However I'm not sure if this is legal in the sense of OOP design. I can't find any real info stating it's ok to do this. I'm worried PHP may "patch" this in future versions if this is not a valid and break my scripts.

Thanks for the help.

+2  A: 

It is. Static methods are usually nothing more than helper methods that have code you possibly don't want to be public.

The other common object-oriented languages I can think of have it too (C++, Java, C#). I really don't think they're ever going to remove that feature.

Besides, the guys at PHP are slow at breaking existing features, so I wouldn't worry too much about it.

zneak
uhm...isn't final the keyword you want to use to protect your code?
dierre
@dierre: `final` protects from overriding/inheritance, but it doesn't protect access.
zneak
oh, ok. Sorry I thought by saying "have code you possibly don't want to be public" was referred to the possibility of override/inherit it.
dierre