summaryrefslogtreecommitdiff
path: root/Zend/tests/type_declarations/typed_properties_073.phpt
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/tests/type_declarations/typed_properties_073.phpt')
-rw-r--r--Zend/tests/type_declarations/typed_properties_073.phpt44
1 files changed, 44 insertions, 0 deletions
diff --git a/Zend/tests/type_declarations/typed_properties_073.phpt b/Zend/tests/type_declarations/typed_properties_073.phpt
new file mode 100644
index 0000000000..7f9b4ff2de
--- /dev/null
+++ b/Zend/tests/type_declarations/typed_properties_073.phpt
@@ -0,0 +1,44 @@
+--TEST--
+Typed property must cast when used with &__get()
+--FILE--
+<?php
+
+class Test {
+ public $prop = "42";
+ public int $val;
+
+ public function &__get($name) {
+ return $this->prop;
+ }
+}
+
+$test = new Test;
+var_dump($test);
+var_dump($val = &$test->val);
+var_dump($test);
+
+$test->prop = "x";
+var_dump($test, $val);
+
+?>
+--EXPECT--
+object(Test)#1 (1) {
+ ["prop"]=>
+ string(2) "42"
+ ["val"]=>
+ uninitialized(int)
+}
+int(42)
+object(Test)#1 (1) {
+ ["prop"]=>
+ &int(42)
+ ["val"]=>
+ uninitialized(int)
+}
+object(Test)#1 (1) {
+ ["prop"]=>
+ &string(1) "x"
+ ["val"]=>
+ uninitialized(int)
+}
+string(1) "x"