This is one of those "my code works, I don't know why" times.
I have a method in an instantiated class that statically calls a method of what is basically a static class. I say "basically" because while coding it I neglected to declare the methods of the class exclusively static. The method in question belongs to the first class but I blindly copy/pasted the code (which was originally internal) and didn't quite update everything, so the $this-> remained even though the method doesn't belong to the class it's within.
So, basically I had this:
class MyClass{
public function callOtherMethod(){
OtherClass::otherMethod();
}
public function myMethod(){
echo 'Tada!';
}
}
class OtherClass{
public function otherMethod(){
echo get_class($this);
$this->myMethod();
}
}
$thing = new MyClass();
$thing->callOtherMethod();
This somehow worked without issue until I did some cleanup and explicitly declared the OtherClass' methods static as they were meant to be. Everything worked because, for some reason I was unaware of, $this while used within OtherClass instead references the instantiated object that called it (i.e. MyClass).
I didn't think this should be possible, should it? I know it's bad coding standards and I'm making revisions to avoid it, but I found it really, really weird.