com php-src: Added test: Zend/tests/type_declarations/typed _properties_049.phpt
| From: | Bob Weinand | Date: | Tue, 24 May 2016 18:43:57 +0000 |
| Subject: | com php-src: Added test: Zend/tests/type_declarations/typed _properties_049.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95533@lists.php.net to get a copy of this message | ||
Commit: 7d0654eb460a0aac2c5102c6ca035a4aa580eed3
Author: Dmitry Stogov <dmitry@zend.com> Tue, 24 May 2016 21:43:57 +0300
Parents: ff19dec4ea0fc80b5ce394f11b8be4fd5953b5cf
Branches: typed_ref_properties
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7d0654eb460a0aac2c5102c6ca035a4aa580eed3
Log:
Added test
Changed paths:
A Zend/tests/type_declarations/typed_properties_049.phpt
Diff:
diff --git a/Zend/tests/type_declarations/typed_properties_049.phpt
b/Zend/tests/type_declarations/typed_properties_049.phpt
new file mode 100644
index 0000000..2e0b068
--- /dev/null
+++ b/Zend/tests/type_declarations/typed_properties_049.phpt
@@ -0,0 +1,52 @@
+--TEST--
+Nullable typed property
+--FILE--
+<?php
+class Foo {
+ public int $foo = null;
+}
+$x = new Foo();
+var_dump($x);
+try {
+ var_dump($x->foo);
+} catch (Throwable $e) {
+ echo $e->getMessage()."\n";
+}
+try {
+ $x->foo = 5;
+} catch (Throwable $e) {
+ echo $e->getMessage()."\n";
+}
+try {
+ var_dump($x->foo);
+} catch (Throwable $e) {
+ echo $e->getMessage()."\n";
+}
+try {
+ $x->foo = null;
+} catch (Throwable $e) {
+ echo $e->getMessage()."\n";
+}
+try {
+ var_dump($x->foo);
+} catch (Throwable $e) {
+ echo $e->getMessage()."\n";
+}
+try {
+ unset($x->foo);
+} catch (Throwable $e) {
+ echo $e->getMessage()."\n";
+}
+try {
+ var_dump($x->foo);
+} catch (Throwable $e) {
+ echo $e->getMessage()."\n";
+}
+try {
+ $x->foo = "ops";
+} catch (Throwable $e) {
+ echo $e->getMessage()."\n";
+}
+?>
+--EXPECTF--
+Fatal error: Default value for properties with integer type can only be integer in
%styped_properties_049.php on line 3