Bug #51886 [NEW]: call_user_func() does not propagate the scope
| From: | vesko at webstudiobulgaria dot com | Date: | Sat, 22 May 2010 14:10:51 +0000 |
| Subject: | Bug #51886 [NEW]: call_user_func() does not propagate the scope | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-150730@lists.php.net to get a copy of this message | ||
From:
Operating system: Debian 5.0
PHP version: 5.3SVN-2010-05-22 (snap)
Package: Scripting Engine problem
Bug Type: Bug
Bug description:call_user_func() does not propagate the scope
Description:
------------
call_user_func() does not propagate the scope when used in calls between
two classes that have no child-parent relation. When they have child-parent
relation as described in this bug entry:
http://bugs.php.net/bug.php?id=47402 it is fine.
As it is put in the "Backward Incompatible Changes" here:
http://www.php.net/manual/en/migration53.incompatible.php
"The call_user_func() family of functions now propagate $this even if the
callee is a parent class. ". I guess it has to do it for classes that have
no relation as well (or if not so the direct call t2::some_method() should
not do it either). As it is at the moment is inconsistent.
P.S. As well I think a better explanation with an example in the docs
should be added for "The call_user_func() family of functions now propagate
$this even if the callee is a parent class.". It is not clear at all what
it is about if one don't get onto the original bug entry:
"http://bugs.php.net/bug.php?id=47402".
I didnt use the original 47402 entry as in fact it is not a bug.
Test script:
---------------
class t1
{
public function __call($method,$args) {
//call_user_func('t2::some_method',$args);//for PHP 5.3
call_user_func(array('t2','some_method'),$args);
t2::some_method();
}
public function existing_method() {
//call_user_func('t2::some_method');//for PHP 5.3
call_user_func(array('t2','some_method'));
t2::some_method();
}
}
class t2
{
public function some_method() {
print isset($this)?'yes':'no';
print PHP_EOL;
}
}
$t1 = new t1;
$t1->existing_method();
$t1->non_existing_method();//use overloading
Expected result:
----------------
yes
yes
yes
yes
Actual result:
--------------
no
yes
no
yes
--
Edit bug report at http://bugs.php.net/bug.php?id=51886&edit=1
--
Try a snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=51886&r=trysnapshot52
Try a snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=51886&r=trysnapshot53
Try a snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=51886&r=trysnapshot60
Fixed in SVN: http://bugs.php.net/fix.php?id=51886&r=fixed
Fixed in SVN and need be documented: http://bugs.php.net/fix.php?id=51886&r=needdocs
Fixed in release: http://bugs.php.net/fix.php?id=51886&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=51886&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=51886&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=51886&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=51886&r=support
Expected behavior: http://bugs.php.net/fix.php?id=51886&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=51886&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=51886&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=51886&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=51886&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=51886&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=51886&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=51886&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=51886&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=51886&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=51886&r=mysqlcfg