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 = '0' . str_repeat('A', 39);
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?>
36--EXPECTF--
37array(1) {
38  [0]=>
39  string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
40}
41array(1) {
42  [0]=>
43  string(0) ""
44}
45
46Warning: A non-numeric value encountered in %s on line %d
47array(1) {
48  [0]=>
49  string(40) "0AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
50}
51int(134512640)
52array(1) {
53  [0]=>
54  string(40) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
55}
56string(48) "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
57