com php-src: only allow widening int to float at runtime: Zend/tests/type_declarations/typed_properties_027 .phpt Zend/zend_execute.c
| From: | Bob Weinand | Date: | Wed, 16 Mar 2016 16:00:56 +0000 |
| Subject: | com php-src: only allow widening int to float at runtime: Zend/tests/type_declarations/typed_properties_027 .phpt Zend/zend_execute.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95684@lists.php.net to get a copy of this message | ||
Commit: 87f1a37f3839299c5bdb8fd12d0d343c0aae9964
Author: Joe Watkins <krakjoe@php.net> Wed, 16 Mar 2016 16:00:56 +0000
Parents: db9e5743519756080278646ab0d8d055c86a0ae4
Branches: typed_ref_properties
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=87f1a37f3839299c5bdb8fd12d0d343c0aae9964
Log:
only allow widening int to float at runtime
Changed paths:
A Zend/tests/type_declarations/typed_properties_027.phpt
M Zend/zend_execute.c
Diff:
diff --git a/Zend/tests/type_declarations/typed_properties_027.phpt
b/Zend/tests/type_declarations/typed_properties_027.phpt
new file mode 100644
index 0000000..9cb7c07
--- /dev/null
+++ b/Zend/tests/type_declarations/typed_properties_027.phpt
@@ -0,0 +1,17 @@
+--TEST--
+Test typed properties int must be allowed to widen to float only at runtime
+--FILE--
+<?php
+class Foo {
+
+ public int $bar = 1.1;
+}
+?>
+--EXPECTF--
+Fatal error: Typed property Foo::$bar must be integer, float used in %s on line 4
+
+
+
+
+
+
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index d071590..b02d548 100644
--- a/Zend/zend_execute..c
+++ b/Zend/zend_execute.c
@@ -814,7 +814,7 @@ zend_bool zend_verify_property_type(zend_class_entry *scope, zend_string *name,
}
case IS_LONG:
- if (Z_TYPE_P(property) == IS_DOUBLE)
+ if (runtime && Z_TYPE_P(property) == IS_DOUBLE)
return 1;
default: