Edit report at http://bugs.php.net/bug.php?id=51524&edit=1
ID: 51524 Comment by: david71rj at gmail dot com Reported by: david71rj at gmail dot com Summary: Class static method confusion Status: Open Type: Bug Package: Scripting Engine problem Operating System: Windows 7/64 PHP Version: 5.3.2 New Comment: Not make sense, a call static is call static, don't can exist $this. In counterpart, if the user need pass a object reference, he must be to specific how a parameter. public function x($object = null){ if($object && get_class($object) == 'B') { // Now make sense, but not is $this } } Bye. Previous Comments: ------------------------------------------------------------------------ [2010-04-10 18:06:02] paj...@php.net Not sure you can simply bogus it "because that's the way php4 works" :) Should we not fix it in trunk instead? Or at least leave that request open until we have a decision. ------------------------------------------------------------------------ [2010-04-10 17:49:31] johan...@php.net If a static method is called from an object context the callers $this is sent. This i due to compatibility with the way PHP 4 worked. ------------------------------------------------------------------------ [2010-04-10 03:37:23] david71rj at gmail dot com Description: ------------ If I use public method as static in a method of a second function, this send $this from second class, don't of the first. Test script: --------------- http://codepad.org/8hW4Qtbo Expected result: ---------------- array 0 => string 'static' (length=6) 1 => int 1 array 0 => string 'object' (length=6) 1 => object(test)[2] 2 => int 1 array 0 => string 'static' (length=6) 1 => int 1 array 0 => string 'object' (length=6) 1 => object(test)[3] <<<<<<<<<<<<<<< OKAY 2 => int 1 Actual result: -------------- array 0 => string 'static' (length=6) 1 => int 1 array 0 => string 'object' (length=6) 1 => object(test)[2] 2 => int 1 array 0 => string 'static' (length=6) 1 => int 1 array 0 => string 'object' (length=6) 1 => object(test2)[3] <<<<<<<<< WHY "test2" IF DON'T? 2 => int 1 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/bug.php?id=51524&edit=1