summaryrefslogtreecommitdiff
path: root/Zend/tests/bug32290.phpt
blob: 89da67b1959f03a52e7dc0b164aa13c7b8945a12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
--TEST--
Bug #32290 (calling call_user_func_array() ends in infinite loop within child class)
--INI--
error_reporting=8191
--FILE--
<?php

class TestA
{
	public function doSomething($i)
	{
		echo __METHOD__ . "($i)\n";
		return --$i;
	}

	public function doSomethingThis($i)
	{
		echo __METHOD__ . "($i)\n";
		return --$i;
	}

	public function doSomethingParent($i)
	{
		echo __METHOD__ . "($i)\n";
		return --$i;
	}

	public function doSomethingParentThis($i)
	{
		echo __METHOD__ . "($i)\n";
		return --$i;
	}

	public static function doSomethingStatic($i)
	{
		echo __METHOD__ . "($i)\n";
		return --$i;
	}
}

class TestB extends TestA
{
	public function doSomething($i)
	{
		echo __METHOD__ . "($i)\n";
		$i++;
		if ($i >= 5) return 5;
		return call_user_func_array(array("TestA", "doSomething"), array($i));
	}

	public function doSomethingThis($i)
	{
		echo __METHOD__ . "($i)\n";
		$i++;
		if ($i >= 5) return 5;
		return call_user_func_array(array($this, "TestA::doSomethingThis"), array($i));
	}

	public function doSomethingParent($i)
	{
		echo __METHOD__ . "($i)\n";
		$i++;
		if ($i >= 5) return 5;
		return call_user_func_array(array("parent", "doSomethingParent"), array($i));
	}

	public function doSomethingParentThis($i)
	{
		echo __METHOD__ . "($i)\n";
		$i++;
		if ($i >= 5) return 5;
		return call_user_func_array(array($this, "parent::doSomethingParentThis"), array($i));
	}

	public static function doSomethingStatic($i)
	{
		echo __METHOD__ . "($i)\n";
		$i++;
		if ($i >= 5) return 5;
		return call_user_func_array(array("TestA", "doSomethingStatic"), array($i));
	}
}

$x = new TestB();
echo "===A===\n";
var_dump($x->doSomething(1));
echo "\n===B===\n";
var_dump($x->doSomethingThis(1));
echo "\n===C===\n";
var_dump($x->doSomethingParent(1));
echo "\n===D===\n";
var_dump($x->doSomethingParentThis(1));
echo "\n===E===\n";
var_dump($x->doSomethingStatic(1));

?>
===DONE===
<?php exit(0); ?>
--EXPECTF--
===A===
TestB::doSomething(1)
TestA::doSomething(2)
int(1)

===B===
TestB::doSomethingThis(1)
TestA::doSomethingThis(2)
int(1)

===C===
TestB::doSomethingParent(1)
TestA::doSomethingParent(2)
int(1)

===D===
TestB::doSomethingParentThis(1)
TestA::doSomethingParentThis(2)
int(1)

===E===
TestB::doSomethingStatic(1)
TestA::doSomethingStatic(2)
int(1)
===DONE===