php-src/Zend/tests/bug32290.phpt
Antony Dovgal 37797ff7bf fix tests
2007-03-06 19:25:46 +00:00

124 lines
2.3 KiB
PHP
Executable File

--TEST--
Bug #32290 (calling call_user_func_array() ends in infinite loop within child class)
--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===
--EXPECTF--
===A===
TestB::doSomething(1)
Warning: call_user_func_array() expects parameter 1 to be valid callback, array given in %s on line %d
NULL
===B===
TestB::doSomethingThis(1)
TestA::doSomethingThis(2)
int(1)
===C===
TestB::doSomethingParent(1)
Warning: call_user_func_array() expects parameter 1 to be valid callback, array given in %s on line %d
NULL
===D===
TestB::doSomethingParentThis(1)
TestA::doSomethingParentThis(2)
int(1)
===E===
TestB::doSomethingStatic(1)
TestA::doSomethingStatic(2)
int(1)
===DONE===