1--TEST-- 2Bug #55871 (Interruption in substr_replace()) (PHP7) 3--FILE-- 4<?php 5class test1 { 6 public function __toString() { 7 preg_match('//', '', $GLOBALS['my_var']); 8 return ''; 9 } 10} 11 12class test2 { 13 public function __toString() { 14 $GLOBALS['my_var'] += 0x08048000; 15 return ''; 16 } 17} 18 19class test3 { 20 public function __toString() { 21 $GLOBALS['my_var'] .= "AAAAAAAA"; 22 return ''; 23 } 24} 25 26$my_var = str_repeat('A', 40); 27$out = substr_replace(array(&$my_var), array(new test1), 40, 0); 28var_dump($out, $my_var); 29$my_var = str_repeat('A', 40); 30$out = substr_replace(array(&$my_var), array(new test2), 40, 0); 31var_dump($out, $my_var); 32$my_var = str_repeat('A', 40); 33$out = substr_replace(array(&$my_var), array(new test3), 40, 0); 34var_dump($out, $my_var); 35--EXPECTF-- 36array(1) { 37 [0]=> 38 string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" 39} 40array(1) { 41 [0]=> 42 string(0) "" 43} 44array(1) { 45 [0]=> 46 string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" 47} 48int(134512640) 49array(1) { 50 [0]=> 51 string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" 52} 53string(48) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA" 54