From:             nlhowell at cableone dot net
Operating system: WinXP Pro 2600 SP1
PHP version:      5CVS-2004-06-07 (dev)
PHP Bug Type:     Class/Object related
Bug description:  'parent' and 'self' behave differently with call_user_func

Description:
------------
If you use call_user_func(array("parent", "somefunc")), an error is
triggered:
call_user_func(parent::x) [function.call-user-func.html]: First argument
is expected to be a valid callback

However, doing this with 'self' instead of 'parent' works fine, and
behaves as expected.

This may be a recurrence of Bug #26543, in which neither 'parent' nor
'self' could be used in call_user_func, so you might want to take a look
at that.

Reproduce code:
---------------
<?php
class P { function __construct() { $args = func_get_args();
print_r($args); } }
class D { function __construct() { $args = func_get_args();
call_user_func_array(array("parent", "__construct")); } }
class C { function __construct() { $args = func_get_args();
call_user_func_array(array("self", "func"), $args); } function func() {
$args = func_get_args(); print_r($args); } }
$c = new C(1,2,3,4); // behaves as expected
$d = new D(1,2,3,4); // doesn't behave as expected
?>

Expected result:
----------------
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) 
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) 

Actual result:
--------------
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 ) 
Warning: call_user_func(parent::x) [function.call-user-func.html]: First
argument is expected to be a valid callback in
c:\Inetpub\wwwroot\test.php5 on line 3

-- 
Edit bug report at http://bugs.php.net/?id=28674&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=28674&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=28674&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=28674&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=28674&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=28674&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=28674&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=28674&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=28674&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=28674&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=28674&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=28674&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=28674&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=28674&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=28674&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=28674&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=28674&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=28674&r=float

Reply via email to