I’d like to know if there’s a technical reason of why PHP’s designers decided to invoke a static method using Class::static_method()
instead of Class->static_method()
(like any other method).
Does the syntax change reflect any technical requirement?
I’m asking this because the syntax for every single other language I know to invoke a method is always the same, despite it being static or not.
2
Invocation of instance methods is not Class->method()
but $object->method()
. Additionally, semantics of the ->
operator is that it passes the instance of the class (vulgo: object) to the method in a hidden parameter; class methods differ from instance methods in that they, at best, have access to class attributes.