summaryrefslogtreecommitdiff
path: root/Zend/zend_compile.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2016-05-23 10:14:26 +0300
committerDmitry Stogov <dmitry@zend.com>2016-05-23 10:14:26 +0300
commit0cdbabe558dbdbe3bab6ba9102dba8311a5ea7f7 (patch)
tree9f92e845ca86e18cf687cab3a4285a7a7a722cb4 /Zend/zend_compile.c
parent0d62dfdf81fb7710c20a46a75ad6166e25e50a12 (diff)
parent56c3d75780b7c2faf290722a615fd2d797d2f041 (diff)
downloadphp-git-0cdbabe558dbdbe3bab6ba9102dba8311a5ea7f7.tar.gz
Merge branch 'nullable_types' of github.com:morrisonlevi/php-src
* 'nullable_types' of github.com:morrisonlevi/php-src: Fix bug #71428 Add nullable parameter types Implement nullable return types.
Diffstat (limited to 'Zend/zend_compile.c')
-rw-r--r--Zend/zend_compile.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index e401ce2430..0994681c20 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4889,7 +4889,7 @@ static void zend_compile_typename(zend_ast *ast, zend_arg_info *arg_info) /* {{{
zend_uchar type = zend_lookup_builtin_type_by_name(class_name);
if (type != 0) {
- if (ast->attr != ZEND_NAME_NOT_FQ) {
+ if ((ast->attr & ZEND_NAME_NOT_FQ) != ZEND_NAME_NOT_FQ) {
zend_error_noreturn(E_COMPILE_ERROR,
"Scalar type declaration '%s' must be unqualified",
ZSTR_VAL(zend_string_tolower(class_name)));
@@ -4929,6 +4929,11 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */
arg_infos->allow_null = 0;
arg_infos->class_name = NULL;
+ if (return_type_ast->attr & ZEND_TYPE_NULLABLE) {
+ arg_infos->allow_null = 1;
+ return_type_ast->attr &= ~ZEND_TYPE_NULLABLE;
+ }
+
zend_compile_typename(return_type_ast, arg_infos);
arg_infos++;
@@ -5017,9 +5022,10 @@ void zend_compile_params(zend_ast *ast, zend_ast *return_type_ast) /* {{{ */
&& (Z_TYPE(default_node.u.constant) == IS_NULL
|| (Z_TYPE(default_node.u.constant) == IS_CONSTANT
&& strcasecmp(Z_STRVAL(default_node.u.constant), "NULL") == 0));
+ zend_bool is_explicitly_nullable = (type_ast->attr & ZEND_TYPE_NULLABLE) == ZEND_TYPE_NULLABLE;
op_array->fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
- arg_info->allow_null = has_null_default;
+ arg_info->allow_null = has_null_default || is_explicitly_nullable;
zend_compile_typename(type_ast, arg_info);