#25069 [Opn->Fbk]: methods called w call_user_func have no $this
| From: | sniper@php.net | Date: | Sat, 29 Nov 2003 01:55:23 +0000 |
| Subject: | #25069 [Opn->Fbk]: methods called w call_user_func have no $this | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-51280@lists.php.net to get a copy of this message | ||
ID: 25069
Updated by: sniper@php.net
Reported By: tater at potatoe dot com
-Status: Open
+Status: Feedback
Bug Type: Zend Engine 2 problem
Operating System: *
PHP Version: 5CVS-2003-08-13 (dev)
New Comment:
PHP Warning: call_user_func(self::a): First argument is expected to be
a valid callback in /home/jani/t.php on line 15
WHY would you even do this inside a class?!
Previous Comments:
------------------------------------------------------------------------
[2003-08-13 04:04:07] tater at potatoe dot com
Description:
------------
If you call an object's method, $x->foo(), and then
call parent:;bar() (or self:;bar() or xyz::abc()),
$this will be defined inside bar() and point to the
original object ($x). But if you use call_user_func()
or call_user_func_array(), $this is not defined.
Reproduce code:
---------------
class foo
{
function a()
{
if (isset($this))
var_dump($this);
else
print "\$this not defined.\n";
}
function b()
{
self::a();
call_user_func(array('self','a'));
}
}
$x = new foo;
$x->b();
Expected result:
----------------
object(foo)#1 (0) {
}
object(foo)#1 (0) {
}
Actual result:
--------------
object(foo)#1 (0) {
}
$this not defined.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=25069&edit=1