Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 11 additions & 30 deletions Zend/tests/bug48770.phpt
Original file line number Diff line number Diff line change
@@ -1,53 +1,34 @@
--TEST--
Bug #48770 (call_user_func_array() fails to call parent from inheriting class)
--XFAIL--
See Bug #48770
--FILE--
<?php

class A {
public function func($str) {
var_dump(__METHOD__ .': '. $str);
}
private function func2($str) {
var_dump(__METHOD__ .': '. $str);
}
protected function func3($str) {
var_dump(__METHOD__ .': '. $str);
}
private function func22($str) {
var_dump(__METHOD__ .': '. $str);
public function func($arg) {
echo "A::func called\n";
}
}

class B extends A {
public function func($str) {
static $avoid_crash = 0;

if ($avoid_crash++ == 1) {
print "This method shouldn't be called when using parent::func!\n";
return;
}

call_user_func_array(array($this, 'parent::func'), array($str));
}
private function func2($str) {
var_dump(__METHOD__ .': '. $str);
public function func($arg) {
echo "B::func called\n";
}
protected function func3($str) {
var_dump(__METHOD__ .': '. $str);

public function callFuncInParent($arg) {
call_user_func_array(array($this, 'parent::func'), array($arg));
}
}

class C extends B {
public function func($str) {
public function func($arg) {
echo "C::func called\n";
parent::func($str);
}
}

$c = new C;
$c->func('This should work!');
$c->callFuncInParent('Which function will be called??');

?>
--EXPECT--
string(26) "A::func: This should work!"
B::func called
10 changes: 4 additions & 6 deletions Zend/tests/bug48770_2.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Bug #48770 (call_user_func_array() fails to call parent from inheriting class)
--XFAIL--
See Bug #48770
--FILE--
<?php

Expand Down Expand Up @@ -56,7 +54,7 @@ $c->func('This should work!');

?>
--EXPECT--
string(27) "A::func2: This should work!"
string(27) "A::func3: This should work!"
call_user_func_array(): Argument #1 ($function) must be a valid callback, cannot access private method A::func22()
call_user_func_array(): Argument #1 ($function) must be a valid callback, class 'A' does not have a method 'inexistent'
string(27) "B::func2: This should work!"
string(27) "B::func3: This should work!"
call_user_func_array(): Argument #1 ($function) must be a valid callback, cannot access private method B::func22()
call_user_func_array(): Argument #1 ($function) must be a valid callback, class 'B' does not have a method 'inexistent'
7 changes: 1 addition & 6 deletions Zend/tests/bug48770_3.phpt
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
--TEST--
Bug #48770 (call_user_func_array() fails to call parent from inheriting class)
--XFAIL--
See Bug #48770
--FILE--
<?php

Expand All @@ -15,9 +13,6 @@ class A {
protected function func3($str) {
var_dump(__METHOD__ .': '. $str);
}
private function func22($str) {
var_dump(__METHOD__ .': '. $str);
}
}

class B extends A {
Expand Down Expand Up @@ -52,4 +47,4 @@ $c->func('This should work!');
--EXPECT--
string(27) "B::func2: This should work!"
string(27) "B::func3: This should work!"
call_user_func_array(): Argument #1 ($function) must be a valid callback, class 'B' does not have a method 'inexistent'
call_user_func_array(): Argument #1 ($function) must be a valid callback, class 'C' does not have a method 'inexistent'