summaryrefslogtreecommitdiff
path: root/Zend/zend_inheritance.c
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_inheritance.c')
-rw-r--r--Zend/zend_inheritance.c40
1 files changed, 36 insertions, 4 deletions
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 44abfb6ffb..7dc6bfc1f7 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -167,6 +167,20 @@ char *zend_visibility_string(uint32_t fn_flags) /* {{{ */
}
/* }}} */
+static zend_always_inline zend_bool zend_iterable_compatibility_check(zend_arg_info *arg_info) /* {{{ */
+{
+ if (arg_info->type_hint == IS_ARRAY) {
+ return 1;
+ }
+
+ if (arg_info->class_name && zend_string_equals_literal_ci(arg_info->class_name, "Traversable")) {
+ return 1;
+ }
+
+ return 0;
+}
+/* }}} */
+
static int zend_do_perform_type_hint_check(const zend_function *fe, zend_arg_info *fe_arg_info, const zend_function *proto, zend_arg_info *proto_arg_info) /* {{{ */
{
if (ZEND_LOG_XOR(fe_arg_info->class_name, proto_arg_info->class_name)) {
@@ -314,9 +328,18 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
} else {
proto_arg_info = &proto->common.arg_info[proto->common.num_args];
}
-
+
if (!zend_do_perform_type_hint_check(fe, fe_arg_info, proto, proto_arg_info)) {
- return 0;
+ switch (fe_arg_info->type_hint) {
+ case IS_ITERABLE:
+ if (!zend_iterable_compatibility_check(proto_arg_info)) {
+ return 0;
+ }
+ break;
+
+ default:
+ return 0;
+ }
}
// This introduces BC break described at https://bugs.php.net/bug.php?id=72119
@@ -338,9 +361,18 @@ static zend_bool zend_do_perform_implementation_check(const zend_function *fe, c
if (!(fe->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE)) {
return 0;
}
-
+
if (!zend_do_perform_type_hint_check(fe, fe->common.arg_info - 1, proto, proto->common.arg_info - 1)) {
- return 0;
+ switch (proto->common.arg_info[-1].type_hint) {
+ case IS_ITERABLE:
+ if (!zend_iterable_compatibility_check(fe->common.arg_info - 1)) {
+ return 0;
+ }
+ break;
+
+ default:
+ return 0;
+ }
}
if (fe->common.arg_info[-1].allow_null && !proto->common.arg_info[-1].allow_null) {