1--TEST--
2Passing assignments by reference
3--FILE--
4<?php
5
6function f(&$a) {
7  var_dump($a);
8  $a = "a.changed";
9}
10
11echo "\n\n---> Pass constant assignment by reference:\n";
12try {
13    f($a="a.original");
14    var_dump($a);
15} catch (Throwable $e) {
16    echo "Exception: " . $e->getMessage() ."\n";
17}
18
19echo "\n\n---> Pass variable assignment by reference:\n";
20try {
21    unset($a);
22    $a = "a.original";
23    f($b = $a);
24    var_dump($a);
25} catch (Throwable $e) {
26    echo "Exception: " . $e->getMessage() ."\n";
27}
28
29echo "\n\n---> Pass reference assignment by reference:\n";
30try {
31    unset($a, $b);
32    $a = "a.original";
33    f($b =& $a);
34    var_dump($a);
35} catch (Throwable $e) {
36    echo "Exception: " . $e->getMessage() ."\n";
37}
38
39echo "\n\n---> Pass concat assignment by reference:\n";
40try {
41    unset($a, $b);
42    $b = "b.original";
43    $a = "a.original";
44    f($b .= $a);
45    var_dump($a);
46} catch (Throwable $e) {
47    echo "Exception: " . $e->getMessage() ."\n";
48}
49
50?>
51--EXPECT--
52---> Pass constant assignment by reference:
53Exception: f(): Argument #1 ($a) could not be passed by reference
54
55
56---> Pass variable assignment by reference:
57Exception: f(): Argument #1 ($a) could not be passed by reference
58
59
60---> Pass reference assignment by reference:
61string(10) "a.original"
62string(9) "a.changed"
63
64
65---> Pass concat assignment by reference:
66Exception: f(): Argument #1 ($a) could not be passed by reference
67