diff options
Diffstat (limited to 'Zend/tests/type_declarations/typed_properties_057.phpt')
-rw-r--r-- | Zend/tests/type_declarations/typed_properties_057.phpt | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/Zend/tests/type_declarations/typed_properties_057.phpt b/Zend/tests/type_declarations/typed_properties_057.phpt new file mode 100644 index 0000000000..6b53a42600 --- /dev/null +++ b/Zend/tests/type_declarations/typed_properties_057.phpt @@ -0,0 +1,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-- +Typed property A::$foo must be string, int used +string(3) "100" +Typed property A::$foo must be string, int used +string(3) "100" |