#47891 [Opn->WFx]: static method bound to calling object
| From: | colder@php.net | Date: | Fri, 03 Apr 2009 16:52:17 +0000 |
| Subject: | #47891 [Opn->WFx]: static method bound to calling object | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-135528@lists.php.net to get a copy of this message | ||
ID: 47891
Updated by: colder@php.net
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