summaryrefslogtreecommitdiff
path: root/Zend/tests/ctor_promotion_basic.phpt
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-03-24 13:18:28 +0100
committerNikita Popov <nikita.ppv@gmail.com>2020-06-05 15:15:51 +0200
commit064b4644484d38e9dce40aef7e8e0e8190e9d863 (patch)
treeceb34fd4bc375ea0accdf3f8b1b15c389c7e103a /Zend/tests/ctor_promotion_basic.phpt
parent91f283a0bfc6792d84fb9a6361e21f6f33769c4d (diff)
downloadphp-git-064b4644484d38e9dce40aef7e8e0e8190e9d863.tar.gz
Implement "Constructor Promotion" RFC
RFC: https://wiki.php.net/rfc/constructor_promotion Closes GH-5291.
Diffstat (limited to 'Zend/tests/ctor_promotion_basic.phpt')
-rw-r--r--Zend/tests/ctor_promotion_basic.phpt21
1 files changed, 21 insertions, 0 deletions
diff --git a/Zend/tests/ctor_promotion_basic.phpt b/Zend/tests/ctor_promotion_basic.phpt
new file mode 100644
index 0000000000..206f99fd40
--- /dev/null
+++ b/Zend/tests/ctor_promotion_basic.phpt
@@ -0,0 +1,21 @@
+--TEST--
+Constructor promotion (basic example)
+--FILE--
+<?php
+
+class Point {
+ public function __construct(public int $x, public int $y, public int $z) {}
+}
+
+$point = new Point(1, 2, 3);
+
+// Check that properties really are typed.
+try {
+ $point->x = "foo";
+} catch (TypeError $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECT--
+Cannot assign string to property Point::$x of type int