xref: /PHP-7.3/ext/reflection/tests/bug42976.phpt (revision 782352c5)
1--TEST--
2Bug #42976 (Crash when constructor for newInstance() or newInstanceArgs() fails)
3--FILE--
4<?php
5
6Class C {
7	function __construct(&$x) {
8		$x = "x.changed";
9	}
10}
11
12$x = "x.original";
13new C($x); // OK
14var_dump($x);
15
16$rc = new ReflectionClass('C');
17$x = "x.original";
18$rc->newInstance($x); // causes crash
19var_dump($x);
20$x = "x.original";
21$rc->newInstanceArgs(array($x)); // causes crash
22var_dump($x);
23
24echo "Done\n";
25?>
26--EXPECTF--
27string(9) "x.changed"
28
29Warning: Parameter 1 to C::__construct() expected to be a reference, value given in %sbug42976.php on line 15
30string(10) "x.original"
31
32Warning: Parameter 1 to C::__construct() expected to be a reference, value given in %sbug42976.php on line 18
33string(10) "x.original"
34Done
35