Skip to content

Commit b428bc9

Browse files
ext/reflection: voidify format_default_value() (#19234)
This function always returned SUCCESS unconditionally; removing the return type revealed some impossible code for handling FAILURE that could also be removed.
1 parent 7c1e461 commit b428bc9

File tree

1 file changed

+4
-12
lines changed

1 file changed

+4
-12
lines changed

ext/reflection/php_reflection.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -716,7 +716,7 @@ static zval *get_default_from_recv(zend_op_array *op_array, uint32_t offset) {
716716
return RT_CONSTANT(recv, recv->op2);
717717
}
718718

719-
static int format_default_value(smart_str *str, zval *value) {
719+
static void format_default_value(smart_str *str, zval *value) {
720720
if (smart_str_append_zval(str, value, SIZE_MAX) == SUCCESS) {
721721
/* Nothing to do. */
722722
} else if (Z_TYPE_P(value) == IS_ARRAY) {
@@ -761,7 +761,6 @@ static int format_default_value(smart_str *str, zval *value) {
761761
smart_str_append(str, ast_str);
762762
zend_string_release(ast_str);
763763
}
764-
return SUCCESS;
765764
}
766765

767766
static inline bool has_internal_arg_info(const zend_function *fptr) {
@@ -808,9 +807,7 @@ static void _parameter_string(smart_str *str, zend_function *fptr, struct _zend_
808807
zval *default_value = get_default_from_recv((zend_op_array*)fptr, offset);
809808
if (default_value) {
810809
smart_str_appends(str, " = ");
811-
if (format_default_value(str, default_value) == FAILURE) {
812-
return;
813-
}
810+
format_default_value(str, default_value);
814811
}
815812
}
816813
}
@@ -1055,9 +1052,7 @@ static void _property_string(smart_str *str, zend_property_info *prop, const cha
10551052
zval *default_value = property_get_default(prop);
10561053
if (default_value && !Z_ISUNDEF_P(default_value)) {
10571054
smart_str_appends(str, " = ");
1058-
if (format_default_value(str, default_value) == FAILURE) {
1059-
return;
1060-
}
1055+
format_default_value(str, default_value);
10611056
}
10621057
}
10631058

@@ -7181,10 +7176,7 @@ ZEND_METHOD(ReflectionAttribute, __toString)
71817176
smart_str_appends(&str, " = ");
71827177
}
71837178

7184-
if (format_default_value(&str, &attr->data->args[i].value) == FAILURE) {
7185-
smart_str_free(&str);
7186-
RETURN_THROWS();
7187-
}
7179+
format_default_value(&str, &attr->data->args[i].value);
71887180

71897181
smart_str_appends(&str, " ]\n");
71907182
}

0 commit comments

Comments
 (0)