ID: 28674
Updated by: [EMAIL PROTECTED]
Reported By: nlhowell at cableone dot net
-Status: Open
+Status: Bogus
Bug Type: Class/Object related
Operating System: WinXP Pro 2600 SP1
PHP Version: 5CVS-2004-06-07 (dev)
New Comment:
In order to use 'parent' the calling class must be extended from a
class, and have the method defined.
Previous Comments:
------------------------------------------------------------------------
[2004-06-07 16:18:01] nlhowell at cableone dot net
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 this bug report at http://bugs.php.net/?id=28674&edit=1