1--TEST--
2Using settype() on a typed property
3--FILE--
4<?php
5
6class Test {
7    public int $x;
8}
9
10$test = new Test;
11$test->x = 42;
12settype($test->x, 'string');
13// Same as $test->x = (string) $test->x.
14// Leaves value unchanged due to coercion
15var_dump($test->x);
16
17try {
18    settype($test->x, 'array');
19} catch (TypeError $e) {
20    echo $e->getMessage(), "\n";
21}
22var_dump($test->x);
23
24?>
25--EXPECT--
26int(42)
27Cannot assign array to reference held by property Test::$x of type int
28int(42)
29