summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/typed_properties_057.phpt
blob: ebec0f48bfae6ba457b4e3e4895f97a6361242d5 (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--
Type change in pre/post-increment (use-after-free)
--FILE--
<?php
declare(strict_types=1);

class A {
	public string $foo;
}

$o = new A;
$o->foo = "1" . str_repeat("0", 2);
try {
	$x = ++$o->foo;
} catch (Throwable $e) {
	echo $e->getMessage() . "\n";
}
var_dump($o->foo);
try {
        $x = $o->foo++;
} catch (Throwable $e) {
        echo $e->getMessage() . "\n";
}
var_dump($o->foo);
unset($o);
?>
--EXPECT--
Cannot assign int to property A::$foo of type string
string(3) "100"
Cannot assign int to property A::$foo of type string
string(3) "100"