diff options
author | Dmitry Stogov <dmitry@zend.com> | 2016-04-06 18:24:34 +0300 |
---|---|---|
committer | Levi Morrison <levim@php.net> | 2016-05-05 09:34:16 -0600 |
commit | 49fe737e585d2bf3cea4df14ef7a1965dc632655 (patch) | |
tree | b1ed13c418e548f56f8f9f7c4eee9764a1fe1ae3 /Zend/zend_inheritance.c | |
parent | 59f35c0ca9abfa72c5393f6c0350759a3f6512d8 (diff) | |
download | php-git-49fe737e585d2bf3cea4df14ef7a1965dc632655.tar.gz |
Implement nullable return types.
Diffstat (limited to 'Zend/zend_inheritance.c')
-rw-r--r-- | Zend/zend_inheritance.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 42283f94dc..df7dbfd63e 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -344,6 +344,10 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c if (!zend_do_perform_type_hint_check(fe, fe->common.arg_info - 1, proto, proto->common.arg_info - 1)) { return 0; } + + if (fe->common.arg_info[-1].allow_null && !proto->common.arg_info[-1].allow_null) { + return 0; + } } return 1; } @@ -506,6 +510,9 @@ static ZEND_COLD zend_string *zend_get_function_declaration(const zend_function if (fptr->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) { smart_str_appends(&str, ": "); + if (fptr->common.arg_info[-1].allow_null) { + smart_str_appendc(&str, '?'); + } zend_append_type_hint(&str, fptr, fptr->common.arg_info - 1, 1); } smart_str_0(&str); @@ -590,7 +597,8 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function * error_verb = "must"; } else if ((parent->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) && (!(child->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) || - !zend_do_perform_type_hint_check(child, child->common.arg_info - 1, parent, parent->common.arg_info - 1))) { + !zend_do_perform_type_hint_check(child, child->common.arg_info - 1, parent, parent->common.arg_info - 1) || + (child->common.arg_info[-1].allow_null && !parent->common.arg_info[-1].allow_null))) { error_level = E_COMPILE_ERROR; error_verb = "must"; } else { |