php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #25069 methods called w call_user_func have no $this
Submitted: 2003-08-13 04:04 UTC Modified: 2004-10-13 09:21 UTC
From: tater at potatoe dot com Assigned:
Status: Closed Package: Feature/Change Request
PHP Version: 5CVS-2003-11-29 (dev) OS: *
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: tater at potatoe dot com
New email:
PHP Version: OS:

 

 [2003-08-13 04:04 UTC] 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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-10-13 02:19 UTC] php at bobsilva dot com
This is fixed in 5.1 CVS
 [2004-10-13 09:21 UTC] derick@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 09 23:01:32 2024 UTC