Skip to content

Commit 4fdcce7

Browse files
committed
Address review comments
Clarify comment Remove unnecessary variable Use ZEND_TYPE_INIT_CLASS_CONST_MASK in zend_compile.c
1 parent 955c721 commit 4fdcce7

File tree

2 files changed

+4
-15
lines changed

2 files changed

+4
-15
lines changed

Zend/zend_API.c

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2784,17 +2784,13 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
27842784
num_args++;
27852785
}
27862786

2787-
bool rebuild_arginfo = false;
27882787
/* If types of arguments have to be checked */
27892788
if (reg_function->common.arg_info && num_args) {
27902789
uint32_t i;
27912790
for (i = 0; i < num_args; i++) {
27922791
zend_internal_arg_info *arg_info = &reg_function->internal_function.arg_info[i];
27932792
ZEND_ASSERT(arg_info->name && "Parameter must have a name");
27942793
if (ZEND_TYPE_IS_SET(arg_info->type)) {
2795-
if (ZEND_TYPE_IS_ITERABLE_FALLBACK(arg_info->type)) {
2796-
rebuild_arginfo = true;
2797-
}
27982794
reg_function->common.fn_flags |= ZEND_ACC_HAS_TYPE_HINTS;
27992795
}
28002796
#if ZEND_DEBUG
@@ -2809,14 +2805,11 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
28092805
}
28102806
}
28112807

2808+
/* Rebuild arginfos if parameter/property types and/or a return type are used */
28122809
if (reg_function->common.arg_info &&
28132810
(reg_function->common.fn_flags & (ZEND_ACC_HAS_RETURN_TYPE|ZEND_ACC_HAS_TYPE_HINTS))) {
28142811
/* Treat return type as an extra argument */
28152812
num_args++;
2816-
rebuild_arginfo = true;
2817-
}
2818-
2819-
if (rebuild_arginfo) {
28202813
/* convert "const char*" class type names into "zend_string*" */
28212814
uint32_t i;
28222815
zend_arg_info *arg_info = reg_function->common.arg_info - 1;
@@ -2865,7 +2858,7 @@ ZEND_API zend_result zend_register_functions(zend_class_entry *scope, const zend
28652858
}
28662859
}
28672860
if (ZEND_TYPE_IS_ITERABLE_FALLBACK(new_arg_info[i].type)) {
2868-
/* Do not warn?
2861+
/* Warning generated an extension load warning which is emitted for every test
28692862
zend_error(E_CORE_WARNING, "iterable type is now a compile time alias for array|Traversable,"
28702863
" regenerate the argument info via the php-src gen_stub build script");
28712864
*/

Zend/zend_compile.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6146,13 +6146,9 @@ static zend_type zend_compile_single_typename(zend_ast *ast)
61466146

61476147
/* Transform iterable into a type union alias */
61486148
if (type_code == IS_ITERABLE) {
6149-
zend_type iterable = (zend_type) ZEND_TYPE_INIT_CLASS(ZSTR_KNOWN(ZEND_STR_TRAVERSABLE), 0, 0);
6150-
ZEND_TYPE_FULL_MASK(iterable) |= MAY_BE_ARRAY;
6151-
// TODO Use this instead? ZEND_TYPE_INIT_CLASS_CONST_MASK(ZSTR_KNOWN(ZEND_STR_TRAVERSABLE), MAY_BE_ARRAY);
61526149
/* Set iterable bit for BC compat during Reflection and string representation of type */
6153-
ZEND_TYPE_FULL_MASK(iterable) |= _ZEND_TYPE_ITERABLE_BIT;
6154-
/* Inform that the type list is a union type */
6155-
ZEND_TYPE_FULL_MASK(iterable) |= _ZEND_TYPE_UNION_BIT;
6150+
zend_type iterable = (zend_type) ZEND_TYPE_INIT_CLASS_CONST_MASK(ZSTR_KNOWN(ZEND_STR_TRAVERSABLE),
6151+
(_ZEND_TYPE_UNION_BIT|MAY_BE_ARRAY|_ZEND_TYPE_ITERABLE_BIT));
61566152
return iterable;
61576153
}
61586154

0 commit comments

Comments
 (0)