In my company’s codebase, i see functions used in both static and object context. For e.g. a class A has a function b() which is called both using A::b() and/or object_of_type_A->b(). I know this throws an error if strict is turned on. But I wanted to know if this is a bad practice and if yes, then why? Thanks for any answers.
Let me know if I don’t make sense anywhere. I would be happy to clarify.
Here’s some test code:
PHP/5.3 warns about static calls to non-static methods, which is fine since they are subject to failure as soon as you want to access
$this. But it does not complain about object context calls to static functions: there’s nothing that can go wrong. This behaviour is documented:So, as far as PHP is concerned, what you found in the code base is not wrong. However, I think it’s slightly confusing.