crux_op wrote:Using static variables/methods from with nonstatic calls....
Frankly it seems like a horrible practice from a strict OO perspective, and from the point of view of anyone who wants to write maintainable programs.
Even the java developers agree with this:
Quote:
Note: You can also refer to static methods with an object reference....
but this is discouraged because it does not make it clear that they are class methods.
http://java.sun.com/docs/books/tutor...classvars.html
That clarifies what's been bothering me about all this (I didn't say anything because unlike you I probably wouldn't have made much sense).
What didn't help was the OP's claims that the static methods were somehow being "inherited" by the instance, as if there was some sort of magic rewriting going on behind the scenes which somehow literally turned a static method into an instance method just because the latter's syntax ($objectname->staticmethod() instead of classname::staticmethod()) was used.
I was thinking, "well, obviously the method isn't going to be written with any access to $this or its methods or properties, only class ones, otherwise it couldn't be a static method itself, and it's certainly not going to create any just 'cos that's how it was called, so given that $objectname is an instanceof classname, of course if $objectname->staticmethod() were to mean anything at all it would be the same as classname::staticmethod(). It's a bit creepy, but the intention is unambiguous since it's not like PHP can have two different functions with the same name (hence the existence of self:: and the necessity of $this->). So what's the issue?"