xref: /PHP-5.5/ext/reflection/tests/bug42976.phpt (revision 4dc1cef4)
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
30
31Warning: ReflectionClass::newInstance(): Invocation of C's constructor failed in %sbug42976.php on line 15
32string(10) "x.original"
33
34Warning: Parameter 1 to C::__construct() expected to be a reference, value given in %sbug42976.php on line 18
35
36Warning: ReflectionClass::newInstanceArgs(): Invocation of C's constructor failed in %sbug42976.php on line 18
37string(10) "x.original"
38Done
39