$this Is Not Of The Current Class

no-email (Damien Seguy), Damien Seguy
Fri, 02 Feb 2024 00:00:00 +0000

$this is a pseudo-variable, that represents the current object of the calling object (dixit the manual): it is often portrayed as representing an object of the current class. This is commonly the case.
Yet, it is possible of this object to be an instance of another class. This happens with a child of the class, in particular when that child hasn't defined a method that is present in the parent. The fallback mechanism will use the parent class.
In the end, this is still compatible.