ID: 47891
Updated by: [email protected]
Reported By: slava at forma dot kharkov dot ua
-Status: Open
+Status: Wont fix
Bug Type: Class/Object related
PHP Version: 5.2.9
New Comment:
This is expected, :: calls a method of a class using th current context
as call context. Hence $this in a::stat is a b object. It will issue a
Strict warning.
It's kept that way in PHP5 for PHP4 backward compatibility reasons but
it may be cleaned up in PHP6.
Previous Comments:
------------------------------------------------------------------------
[2009-04-03 16:36:00] slava at forma dot kharkov dot ua
Description:
------------
this code prints instance of object "b" and doesn't throw any errors or
exceptions. If a::stat has modificator "static" it says "Notice:
Undefined variable: this" and prints null.
Reproduce code:
---------------
class a
{
public function stat()
{
var_dump($this);
}
}
class b
{
public function test()
{
a::stat();
}
}
$b= new b();
$b->test();
Expected result:
----------------
throws some errors or exceptions.
Actual result:
--------------
prints instance of object "b"
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=47891&edit=1