File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / Zend / tests / bug32290.phpt
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue Feb 21 23:47:52 2012 UTC (13 years, 1 month ago) by misho
Branches: php, MAIN
CVS tags: v5_4_3elwix, v5_4_29p0, v5_4_29, v5_4_20p0, v5_4_20, v5_4_17p0, v5_4_17, v5_3_10, HEAD
php

    1: --TEST--
    2: Bug #32290 (calling call_user_func_array() ends in infinite loop within child class)
    3: --INI--
    4: error_reporting=8191
    5: --FILE--
    6: <?php
    7: 
    8: class TestA
    9: {
   10: 	public function doSomething($i)
   11: 	{
   12: 		echo __METHOD__ . "($i)\n";
   13: 		return --$i;
   14: 	}
   15: 
   16: 	public function doSomethingThis($i)
   17: 	{
   18: 		echo __METHOD__ . "($i)\n";
   19: 		return --$i;
   20: 	}
   21: 
   22: 	public function doSomethingParent($i)
   23: 	{
   24: 		echo __METHOD__ . "($i)\n";
   25: 		return --$i;
   26: 	}
   27: 
   28: 	public function doSomethingParentThis($i)
   29: 	{
   30: 		echo __METHOD__ . "($i)\n";
   31: 		return --$i;
   32: 	}
   33: 
   34: 	public static function doSomethingStatic($i)
   35: 	{
   36: 		echo __METHOD__ . "($i)\n";
   37: 		return --$i;
   38: 	}
   39: }
   40: 
   41: class TestB extends TestA
   42: {
   43: 	public function doSomething($i)
   44: 	{
   45: 		echo __METHOD__ . "($i)\n";
   46: 		$i++;
   47: 		if ($i >= 5) return 5;
   48: 		return call_user_func_array(array("TestA", "doSomething"), array($i));
   49: 	}
   50: 
   51: 	public function doSomethingThis($i)
   52: 	{
   53: 		echo __METHOD__ . "($i)\n";
   54: 		$i++;
   55: 		if ($i >= 5) return 5;
   56: 		return call_user_func_array(array($this, "TestA::doSomethingThis"), array($i));
   57: 	}
   58: 
   59: 	public function doSomethingParent($i)
   60: 	{
   61: 		echo __METHOD__ . "($i)\n";
   62: 		$i++;
   63: 		if ($i >= 5) return 5;
   64: 		return call_user_func_array(array("parent", "doSomethingParent"), array($i));
   65: 	}
   66: 
   67: 	public function doSomethingParentThis($i)
   68: 	{
   69: 		echo __METHOD__ . "($i)\n";
   70: 		$i++;
   71: 		if ($i >= 5) return 5;
   72: 		return call_user_func_array(array($this, "parent::doSomethingParentThis"), array($i));
   73: 	}
   74: 
   75: 	public static function doSomethingStatic($i)
   76: 	{
   77: 		echo __METHOD__ . "($i)\n";
   78: 		$i++;
   79: 		if ($i >= 5) return 5;
   80: 		return call_user_func_array(array("TestA", "doSomethingStatic"), array($i));
   81: 	}
   82: }
   83: 
   84: $x = new TestB();
   85: echo "===A===\n";
   86: var_dump($x->doSomething(1));
   87: echo "\n===B===\n";
   88: var_dump($x->doSomethingThis(1));
   89: echo "\n===C===\n";
   90: var_dump($x->doSomethingParent(1));
   91: echo "\n===D===\n";
   92: var_dump($x->doSomethingParentThis(1));
   93: echo "\n===E===\n";
   94: var_dump($x->doSomethingStatic(1));
   95: 
   96: ?>
   97: ===DONE===
   98: <?php exit(0); ?>
   99: --EXPECTF--
  100: ===A===
  101: TestB::doSomething(1)
  102: TestA::doSomething(2)
  103: int(1)
  104: 
  105: ===B===
  106: TestB::doSomethingThis(1)
  107: TestA::doSomethingThis(2)
  108: int(1)
  109: 
  110: ===C===
  111: TestB::doSomethingParent(1)
  112: TestA::doSomethingParent(2)
  113: int(1)
  114: 
  115: ===D===
  116: TestB::doSomethingParentThis(1)
  117: TestA::doSomethingParentThis(2)
  118: int(1)
  119: 
  120: ===E===
  121: TestB::doSomethingStatic(1)
  122: TestA::doSomethingStatic(2)
  123: int(1)
  124: ===DONE===

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>