1--TEST-- 2Bug #72101 (crash on complex code) 3--FILE-- 4<?php 5class PHPUnit_Framework_MockObject_Stub_ReturnCallback { 6 protected $callback; 7 public function __construct($callback) { 8 $this->callback = $callback; 9 } 10 public function invoke($invocation) { 11 return call_user_func_array($this->callback, $invocation->parameters); 12 } 13} 14 15class PHPUnit_Framework_MockObject_InvocationMocker { 16 protected $matchers = []; 17 public function addMatcher( $matcher) { 18 $this->matchers[] = $matcher; 19 } 20 public function invoke( $invocation) { 21 foreach ($this->matchers as $match) { 22 $match->invoked($invocation); 23 } 24 } 25} 26 27class PHPUnit_Framework_MockObject_Matcher { 28 public $stub = null; 29 public function invoked($invocation) { 30 return $this->stub->invoke($invocation); 31 } 32} 33 34class MethodCallbackByReference { 35 public function bar(&$a, &$b, $c) { 36 Legacy::bar($a, $b, $c); 37 } 38 public function callback(&$a, &$b, $c) { 39 $b = 1; 40 } 41} 42class PHPUnit_Framework_MockObject_Invocation_Static { 43 public $parameters; 44 public function __construct(array $parameters) { 45 $this->parameters = $parameters; 46 } 47} 48 49class Mock_MethodCallbackByReference_7b180d26 extends MethodCallbackByReference { 50 public $inv_mocker; 51 public function bar(&$a, &$b, $c) { 52 $arguments = array($a, $b, $c); 53 $result = $this->inv_mocker->invoke( 54 new PHPUnit_Framework_MockObject_Invocation_Static( 55 $arguments 56 ) 57 ); 58 return $result; 59 } 60} 61 62set_error_handler(function() { 63// var_dump(func_get_args()); 64 DoesNotExists::$nope = true; 65}, E_ALL); 66 67$foo = new Mock_MethodCallbackByReference_7b180d26(); 68$InvMocker = new PHPUnit_Framework_MockObject_InvocationMocker(); 69$foo->inv_mocker = $InvMocker; 70$OuterMatcher = new PHPUnit_Framework_MockObject_Matcher(); 71$InvMocker->addMatcher($OuterMatcher); 72$OuterMatcher->methodNameMatcher = null; 73$OuterMatcher->stub = new PHPUnit_Framework_MockObject_Stub_ReturnCallback([$foo, 'callback']); 74$a = $b = $c = 0; 75$foo->bar($a, $b, $c); 76?> 77--EXPECTF-- 78Fatal error: Uncaught Error: Class "DoesNotExists" not found in %s:%d 79Stack trace: 80#0 %sbug72101.php(8): {closure}(2, 'MethodCallbackB...', '%s', 8) 81#1 %sbug72101.php(27): PHPUnit_Framework_MockObject_Stub_ReturnCallback->invoke(Object(PHPUnit_Framework_MockObject_Invocation_Static)) 82#2 %sbug72101.php(19): PHPUnit_Framework_MockObject_Matcher->invoked(Object(PHPUnit_Framework_MockObject_Invocation_Static)) 83#3 %sbug72101.php(52): PHPUnit_Framework_MockObject_InvocationMocker->invoke(Object(PHPUnit_Framework_MockObject_Invocation_Static)) 84#4 %sbug72101.php(72): Mock_MethodCallbackByReference_7b180d26->bar(0, 0, 0) 85#5 {main} 86 thrown in %sbug72101.php on line 61 87