Edit report at http://bugs.php.net/bug.php?id=52969&edit=1
ID: 52969 Comment by: gnuffo1 at gmail dot com Reported by: ircmaxell at yahoo dot com Summary: This defined in static call from within another class Status: Open Type: Bug Package: Class/Object related Operating System: linux PHP Version: 5.3.3 Block user comment: N New Comment: This seems to have existed way back in PHP 4.1: http://www.advogato.org/article/470.html If this is a bug, then I think it should be turned into a feature and documented. It is occasionally useful for trait-like functionality. Previous Comments: ------------------------------------------------------------------------ [2010-10-02 15:24:18] ircmaxell at yahoo dot com Description: ------------ When calling a non-static method statically from within another class (non- inherited), $this is populated with the other object's class. Test script: --------------- class test1 { public function getName() { return $this->name; } } class test2 { public $name = 'foo'; public function getName() { return test1::getName(); } } $obj = new Test2; echo $obj->getName(); Expected result: ---------------- Fatal Error: Using $this when not in object context Actual result: -------------- "foo" is outputted. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=52969&edit=1