com php-src: add void check during compile: Zend/tests/type_d eclarations/typed_properties_017.phpt Zend/zend _compile.c
| From: | Bob Weinand | Date: | Tue, 08 Mar 2016 14:23:31 +0000 |
| Subject: | com php-src: add void check during compile: Zend/tests/type_d eclarations/typed_properties_017.phpt Zend/zend _compile.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-95609@lists.php.net to get a copy of this message | ||
Commit: 8095119b0891661cf0ecc2e9f855a21d7133540b
Author: Joe Watkins <krakjoe@php.net> Tue, 8 Mar 2016 14:23:31 +0000
Parents: 414fb839fcce79dcc2b5d0ba9a485d16c314f737
Branches: typed_ref_properties
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=8095119b0891661cf0ecc2e9f855a21d7133540b
Log:
add void check during compile
Changed paths:
A Zend/tests/type_declarations/typed_properties_017.phpt
M Zend/zend_compile.c
Diff:
diff --git a/Zend/tests/type_declarations/typed_properties_017.phpt
b/Zend/tests/type_declarations/typed_properties_017.phpt
new file mode 100644
index 0000000..4d344b9
--- /dev/null
+++ b/Zend/tests/type_declarations/typed_properties_017.phpt
@@ -0,0 +1,16 @@
+--TEST--
+Test typed no void
+--FILE--
+<?php
+class Foo {
+ public void $int;
+}
+
+$foo = new Foo();
+?>
+--EXPECTF--
+Fatal error: Typed property Foo::$int must not be void in %s on line 3
+
+
+
+
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index bc71fd2..973a850 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -5326,6 +5326,7 @@ void zend_compile_prop_decl(zend_ast *ast) /* {{{ */
zend_string *optional_type_name = NULL;
if (type_ast) {
+
if (type_ast->kind == ZEND_AST_TYPE) {
optional_type = type_ast->attr;
} else {
@@ -5338,9 +5339,18 @@ void zend_compile_prop_decl(zend_ast *ast) /* {{{ */
"Scalar type declaration '%s' must be unqualified",
ZSTR_VAL(zend_string_tolower(class_name)));
}
+
+ if (type == IS_VOID) {
+ zend_error_noreturn(E_COMPILE_ERROR,
+ "Typed property %s::$%s must not be void",
+ ZSTR_VAL(ce->name),
+ ZSTR_VAL(name));
+ }
+
optional_type = type;
} else {
uint32_t fetch_type = zend_get_class_fetch_type_ast(type_ast);
+
if (fetch_type == ZEND_FETCH_CLASS_DEFAULT) {
class_name = zend_resolve_class_name_ast(type_ast);
zend_assert_valid_class_name(class_name);