summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/typed_properties_093.phpt
blob: f0c7ef51a9009240c1c64047edcfb4775a427bbb (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
--TEST--
Typed property assignment by ref with variable name
--FILE--
<?php

class Test {
    public int $prop;
}

$name = new class {
    public function __toString() {
        return 'prop';
    }
};

$test = new Test;
$ref = "foobar";
try {
    $test->$name =& $ref;
} catch (TypeError $e) {
    echo $e->getMessage(), "\n";
}
var_dump($test);

?>
--EXPECT--
Typed property Test::$prop must be int, string used
object(Test)#2 (0) {
  ["prop"]=>
  uninitialized(int)
}