self::
does not in fact mean that the method is part of the same class, it may as well have been inherited from a parent class!
You should not use the semantics of static method calls to differentiate "internal" and "external" methods. There's no real point to it anyway, and you're just abusing language features for something they weren't meant for. Maybe let that be a primary lesson: don't try to invent clever new ways of using language features. Just don't.
You should view methods as small, self contained black boxes. You don't need to know and don't want to know what they do. All you know is that when you call method foo
with parameter $bar
, x will happen or it will return y. You don't care how this happens, just that it does because that's what the method is supposed to do.
As such, static
and non-static methods convey a different use with different limitations. static
methods are supposed to be called when you don't have an object, for example as alternative constructor methods (e.g. DateTime::createFromFormat
).
Further, restricting a method to being static
means it has no access to object instance data, which may limit you in the future. As your project evolves, you may find that your method now needs to take into account some additional data from the object to do its job. If you declared it as non-static from the beginning, all it takes is a little modification to the method itself; to the outside world it still does its job the same way (input → output). However, if you declared it as static
and suddenly find yourself needing to make it non-static, you have to change a lot more code than just that one method.
Bottom line: if your method is not supposed to be exposed publicly because it's nobody's business to call it except for your own class, make it private
. If the method needs to be static
because it must work without object context, make it static
. If it fulfils both requirements, make it private static
. Otherwise, don't.