com php-src: restrict declaration groups: Zend/tests/type_dec larations/typed_properties_018.phpt Zend/zend_c ompile.c
| From: | Bob Weinand | Date: | Wed, 09 Mar 2016 05:10:22 +0000 |
| Subject: | com php-src: restrict declaration groups: Zend/tests/type_dec larations/typed_properties_018.phpt Zend/zend_c ompile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95597@lists.php.net to get a copy of this message | ||
Commit: 7d121581bbb7aef6864ffd3c1d9dcb2a0d995618
Author: Joe Watkins <krakjoe@php.net> Wed, 9 Mar 2016 05:10:22 +0000
Parents: abdde6e2ef1e99a3552a4b242988214a3c7e033d
Branches: typed_ref_properties
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7d121581bbb7aef6864ffd3c1d9dcb2a0d995618
Log:
restrict declaration groups
Changed paths:
A Zend/tests/type_declarations/typed_properties_018.phpt
M Zend/zend_compile.c
Diff:
diff --git a/Zend/tests/type_declarations/typed_properties_018.phpt
b/Zend/tests/type_declarations/typed_properties_018.phpt
new file mode 100644
index 0000000..621e176
--- /dev/null
+++ b/Zend/tests/type_declarations/typed_properties_018.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Test typed no mixing typed and untyped declarations
+--FILE--
+<?php
+class Foo {
+ public int $bar,
+ $qux;
+}
+?>
+--EXPECTF--
+Fatal error: Property Foo::$qux is missing type information in %s on line 3
+
+
+
+
+
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 973a850..0803ab1 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -5304,6 +5304,7 @@ void zend_compile_prop_decl(zend_ast *ast) /* {{{ */
uint32_t flags = list->attr;
zend_class_entry *ce = CG(active_class_entry);
uint32_t i, children = list->children;
+ zend_bool use_optional_types = 0;
if (ce->ce_flags & ZEND_ACC_INTERFACE) {
zend_error_noreturn(E_COMPILE_ERROR, "Interfaces may not include member variables");
@@ -5326,7 +5327,7 @@ void zend_compile_prop_decl(zend_ast *ast) /* {{{ */
zend_string *optional_type_name = NULL;
if (type_ast) {
-
+ use_optional_types = 1;
if (type_ast->kind == ZEND_AST_TYPE) {
optional_type = type_ast->attr;
} else {
@@ -5363,6 +5364,11 @@ void zend_compile_prop_decl(zend_ast *ast) /* {{{ */
optional_type_name = class_name;
}
}
+ } else if (use_optional_types) {
+ zend_error_noreturn(E_COMPILE_ERROR,
+ "Property %s::$%s is missing type information",
+ ZSTR_VAL(ce->name),
+ ZSTR_VAL(name));
}
/* Doc comment has been appended as last element in ZEND_AST_PROP_ELEM ast */