summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/typed_properties_082.phpt
blob: d212f1852cbf40e6dfa59d17a8a58c223c61034c (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
--TEST--
Test typed references to static properties 
--FILE--
<?php

class Test {
    public static int $x = 0;
}

class Test2 extends Test {
    public static $y = 1;
}

$x =& Test::$x;
try {
    $x = "foo";
} catch (TypeError $e) { echo $e->getMessage(), "\n"; }
var_dump($x, Test::$x);

Test::$x =& Test2::$y; // remove the typed ref from $x
$x = "foo";
var_dump($x, Test::$x);

?>
--EXPECT--
Cannot assign string to reference held by property Test::$x of type int
int(0)
int(0)
string(3) "foo"
int(1)