diff options
author | Nikita Popov <nikita.ppv@gmail.com> | 2020-03-24 13:18:28 +0100 |
---|---|---|
committer | Nikita Popov <nikita.ppv@gmail.com> | 2020-06-05 15:15:51 +0200 |
commit | 064b4644484d38e9dce40aef7e8e0e8190e9d863 (patch) | |
tree | ceb34fd4bc375ea0accdf3f8b1b15c389c7e103a /Zend/tests/ctor_promotion_basic.phpt | |
parent | 91f283a0bfc6792d84fb9a6361e21f6f33769c4d (diff) | |
download | php-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.phpt | 21 |
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 |