mirror of
https://github.com/php/php-src.git
synced 2024-12-18 06:21:41 +08:00
Bug 48770 was opened due to conflicting expectations about the behavior of: call_user_func_array(array($this, 'parent::methodName'), array($arg1,$arg2)) The one reporting the 'bug' seemed to think that since the method name was prefixed with `parent::`, it should call the method in the superclass of the *class where this code appears*. However, `$this` might be an instance of a subclass. If so, then it is quite reasonable that `call_user_func_array` will call the method as defined in the superclass of *the receiver*. So the 'bug' is not really a bug. Therefore, there is no need for an XFAIL in the tests. They should just pass. Amend tests to reflect the actual expected behavior of `call_user_func_array`, not what the person who reported bug 48770 thought it should be. Closes GH-5386.
35 lines
631 B
PHP
35 lines
631 B
PHP
--TEST--
|
|
Bug #48770 (call_user_func_array() fails to call parent from inheriting class)
|
|
--FILE--
|
|
<?php
|
|
|
|
class A {
|
|
public function func($arg) {
|
|
echo "A::func called\n";
|
|
}
|
|
}
|
|
|
|
class B extends A {
|
|
public function func($arg) {
|
|
echo "B::func called\n";
|
|
}
|
|
|
|
public function callFuncInParent($arg) {
|
|
call_user_func_array(array($this, 'parent::func'), array($arg));
|
|
}
|
|
}
|
|
|
|
class C extends B {
|
|
public function func($arg) {
|
|
echo "C::func called\n";
|
|
parent::func($str);
|
|
}
|
|
}
|
|
|
|
$c = new C;
|
|
$c->callFuncInParent('Which function will be called??');
|
|
|
|
?>
|
|
--EXPECT--
|
|
B::func called
|