summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/typed_properties_055.phpt
blob: 31d687254c46d7f0af52e6732d9f22b803fac544 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
--TEST--
Test assign to typed property taken by reference
--FILE--
<?php
class A {
	public $foo = 1;
	public int $bar = 2;
}
class B {
	public A $a;
}
$f = function (&$n) {
	var_dump($n);
	$n = "ops";
};
$o = new B;
$o->a = new A;
$f($o->a->foo);
$f($o->a->bar);
?>
--EXPECTF--
int(1)
int(2)

Fatal error: Uncaught TypeError: Cannot assign string to reference held by property A::$bar of type int in %s:%d
Stack trace:
#0 %s(%d): {closure}(2)
#1 {main}
  thrown in %s on line %d