summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/typed_properties_039.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/tests/type_declarations/typed_properties_039.phpt')
-rw-r--r--Zend/tests/type_declarations/typed_properties_039.phpt31
1 files changed, 31 insertions, 0 deletions
diff --git a/Zend/tests/type_declarations/typed_properties_039.phpt b/Zend/tests/type_declarations/typed_properties_039.phpt
new file mode 100644
index 0000000000..62413d804c
--- /dev/null
+++ b/Zend/tests/type_declarations/typed_properties_039.phpt
@@ -0,0 +1,31 @@
+--TEST--
+Repeated assign of a variable to mismatched property type must not succeed
+--FILE--
+<?php
+
+class A {
+ public int $foo;
+}
+
+class B {
+ public A $foo;
+}
+
+$objs = [new A, new A];
+$v = 1;
+
+foreach ($objs as $obj) {
+ $obj->foo = $v;
+ $v = new A;
+ $obj = new B;
+ $obj->foo = $v;
+}
+
+var_dump($objs);
+
+?>
+--EXPECTF--
+Fatal error: Uncaught TypeError: Typed property A::$foo must be int, A used in %s:%d
+Stack trace:
+#0 {main}
+ thrown in %s on line %d