diff options
| author | Xinchen Hui <laruence@gmail.com> | 2016-04-07 13:58:00 +0800 |
|---|---|---|
| committer | Xinchen Hui <laruence@gmail.com> | 2016-04-07 13:58:00 +0800 |
| commit | 079239a7cececfca9344b24f5bb1cca127d4bcc9 (patch) | |
| tree | c02a94788db9aac4f3834a7029ce6af28e905b29 /Zend/zend_inheritance.c | |
| parent | 7e042224a26282938b866a49ca3d4af1b368c0cc (diff) | |
| parent | 5ab950cb2ca362af3f718179f1da430922c1e0dd (diff) | |
| download | php-git-079239a7cececfca9344b24f5bb1cca127d4bcc9.tar.gz | |
Merge branch 'PHP-7.0' of git.php.net:/php-src into PHP-7.0
* 'PHP-7.0' of git.php.net:/php-src:
Remove __halt_compiler from semi-reserved tokens
Fixed Bug #71974 Trans sid will always be send, even if cookies are available
Optimized array_fill(). This is a perfect function for fast creation of packed arrays.
Fixed build
fix merge mistake
fix tests
PostgreSQL's PDOStatement::getColumnMeta() fills in table's name.
fix indent
Fixed bug #71978 (Existence of return type hint affects other compatibility rules)
fix test
fix bug #71667 (emulate how mssql extension names "computed" columns)
update NEWS
add 32-bit specific variont for #62498
skip test on 32-bit
make opcache lockfile path configurable
return zvals instead of strings, cast or not based on stringify attribute
fix test
add skip slow test
Diffstat (limited to 'Zend/zend_inheritance.c')
| -rw-r--r-- | Zend/zend_inheritance.c | 40 |
1 files changed, 27 insertions, 13 deletions
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c index 55a9fdc909..9042b2f0a2 100644 --- a/Zend/zend_inheritance.c +++ b/Zend/zend_inheritance.c @@ -243,11 +243,6 @@ static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_inf return 0; } - if (proto_arg_info->type_hint && proto_arg_info->allow_null && !fe_arg_info->allow_null) { - /* incompatible nullability */ - return 0; - } - return 1; } /* }}} */ @@ -324,6 +319,11 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c return 0; } + if (proto_arg_info->type_hint && proto_arg_info->allow_null && !fe_arg_info->allow_null) { + /* incompatible nullability */ + return 0; + } + /* by-ref constraints on arguments are invariant */ if (fe_arg_info->pass_by_reference != proto_arg_info->pass_by_reference) { return 0; @@ -570,17 +570,31 @@ static void do_inheritance_check_on_method(zend_function *child, zend_function * } if (child->common.prototype && ( - child->common.prototype->common.fn_flags & (ZEND_ACC_ABSTRACT | ZEND_ACC_HAS_RETURN_TYPE) + child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT )) { - if (UNEXPECTED(!zend_do_perform_implementation_check(child, child->common.prototype))) { - zend_string *method_prototype = zend_get_function_declaration(child->common.prototype); - zend_string *child_prototype = zend_get_function_declaration(child); - zend_error_noreturn(E_COMPILE_ERROR, "Declaration of %s must be compatible with %s", ZSTR_VAL(child_prototype), ZSTR_VAL(method_prototype)); - } - } else if (UNEXPECTED(!zend_do_perform_implementation_check(child, parent))) { + parent = child->common.prototype; + } + if (UNEXPECTED(!zend_do_perform_implementation_check(child, parent))) { + int error_level; + const char *error_verb; zend_string *method_prototype = zend_get_function_declaration(parent); zend_string *child_prototype = zend_get_function_declaration(child); - zend_error(E_WARNING, "Declaration of %s should be compatible with %s", ZSTR_VAL(child_prototype), ZSTR_VAL(method_prototype)); + + if (child->common.prototype && ( + child->common.prototype->common.fn_flags & ZEND_ACC_ABSTRACT + )) { + error_level = E_COMPILE_ERROR; + 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))) { + error_level = E_COMPILE_ERROR; + error_verb = "must"; + } else { + error_level = E_WARNING; + error_verb = "should"; + } + zend_error(error_level, "Declaration of %s %s be compatible with %s", ZSTR_VAL(child_prototype), error_verb, ZSTR_VAL(method_prototype)); zend_string_free(child_prototype); zend_string_free(method_prototype); } |
