summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/typed_properties_079.phpt
blob: d189cec6d4ceb81b150b2cc704a07c0e9b88ba26 (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
30
31
32
33
--TEST--
Test static typed properties with references
--FILE--
<?php

class A {
    static iterable $it = [];
    static ?array $a;
}

A::$a = &A::$it;

try {
    A::$it = new ArrayIterator();
} catch (TypeError $e) { var_dump($e->getMessage()); }
var_dump(A::$it);

A::$a = &$a;

A::$it = new ArrayIterator();

try {
    $a = 1;
} catch (TypeError $e) { var_dump($e->getMessage()); }
var_dump($a);

?>
--EXPECT--
string(78) "Cannot assign ArrayIterator to reference held by property A::$a of type ?array"
array(0) {
}
string(68) "Cannot assign int to reference held by property A::$a of type ?array"
NULL