Skip to content

Commit 7ece113

Browse files
committed
wip
1 parent 0c2025c commit 7ece113

File tree

6 files changed

+42
-30
lines changed

6 files changed

+42
-30
lines changed

Zend/zend_API.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -748,46 +748,44 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_or_str_slow(zval *arg, zval **
748748
return true;
749749
}
750750

751-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest, uint32_t arg_num) /* {{{ */
751+
ZEND_API zend_string * ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, uint32_t arg_num) /* {{{ */
752752
{
753753
if (EXPECTED(Z_TYPE_P(arg) < IS_STRING)) {
754754
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("string", arg_num)) {
755-
return 0;
755+
return NULL;
756756
}
757757
convert_to_string(arg);
758-
*dest = Z_STR_P(arg);
758+
return Z_STR_P(arg);
759759
} else if (UNEXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
760760
zend_object *zobj = Z_OBJ_P(arg);
761761
zval obj;
762762
if (zobj->handlers->cast_object(zobj, &obj, IS_STRING) == SUCCESS) {
763763
OBJ_RELEASE(zobj);
764764
ZVAL_COPY_VALUE(arg, &obj);
765-
*dest = Z_STR_P(arg);
766-
return 1;
765+
return Z_STR_P(arg);
767766
}
768-
return 0;
767+
return NULL;
769768
} else {
770-
return 0;
769+
return NULL;
771770
}
772-
return 1;
773771
}
774772
/* }}} */
775773

776-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest, uint32_t arg_num) /* {{{ */
774+
ZEND_API zend_string * ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, uint32_t arg_num) /* {{{ */
777775
{
778776
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
779-
return 0;
777+
return NULL;
780778
}
781-
return zend_parse_arg_str_weak(arg, dest, arg_num);
779+
return zend_parse_arg_str_weak(arg, arg_num);
782780
}
783781
/* }}} */
784782

785-
ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_str_slow(zval *arg, zend_string **dest, uint32_t arg_num)
783+
ZEND_API zend_string * ZEND_FASTCALL zend_flf_parse_arg_str_slow(zval *arg, uint32_t arg_num)
786784
{
787785
if (UNEXPECTED(ZEND_FLF_ARG_USES_STRICT_TYPES())) {
788786
return 0;
789787
}
790-
return zend_parse_arg_str_weak(arg, dest, arg_num);
788+
return zend_parse_arg_str_weak(arg, arg_num);
791789
}
792790

793791
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long, uint32_t arg_num) /* {{{ */
@@ -798,11 +796,15 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_stri
798796
if (zend_parse_arg_long_weak(arg, dest_long, arg_num)) {
799797
*dest_str = NULL;
800798
return 1;
801-
} else if (zend_parse_arg_str_weak(arg, dest_str, arg_num)) {
802-
*dest_long = 0;
803-
return 1;
804799
} else {
805-
return 0;
800+
zend_string *str = zend_parse_arg_str_weak(arg, arg_num);
801+
if (str) {
802+
*dest_long = 0;
803+
*dest_str = str;
804+
return 1;
805+
} else {
806+
return 0;
807+
}
806808
}
807809
}
808810
/* }}} */

Zend/zend_API.h

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2181,14 +2181,14 @@ ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_slow(const zval *arg, zend_long
21812181
ZEND_API bool ZEND_FASTCALL zend_parse_arg_long_weak(const zval *arg, zend_long *dest, uint32_t arg_num);
21822182
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_slow(const zval *arg, double *dest, uint32_t arg_num);
21832183
ZEND_API bool ZEND_FASTCALL zend_parse_arg_double_weak(const zval *arg, double *dest, uint32_t arg_num);
2184-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, zend_string **dest, uint32_t arg_num);
2185-
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, zend_string **dest, uint32_t arg_num);
2184+
ZEND_API zend_string * ZEND_FASTCALL zend_parse_arg_str_slow(zval *arg, uint32_t arg_num);
2185+
ZEND_API zend_string * ZEND_FASTCALL zend_parse_arg_str_weak(zval *arg, uint32_t arg_num);
21862186
ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_slow(zval *arg, zval **dest, uint32_t arg_num);
21872187
ZEND_API bool ZEND_FASTCALL zend_parse_arg_number_or_str_slow(zval *arg, zval **dest, uint32_t arg_num);
21882188
ZEND_API bool ZEND_FASTCALL zend_parse_arg_str_or_long_slow(zval *arg, zend_string **dest_str, zend_long *dest_long, uint32_t arg_num);
21892189

21902190
ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_bool_slow(const zval *arg, bool *dest, uint32_t arg_num);
2191-
ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_str_slow(zval *arg, zend_string **dest, uint32_t arg_num);
2191+
ZEND_API zend_string * ZEND_FASTCALL zend_flf_parse_arg_str_slow(zval *arg, uint32_t arg_num);
21922192
ZEND_API bool ZEND_FASTCALL zend_flf_parse_arg_long_slow(const zval *arg, zend_long *dest, uint32_t arg_num);
21932193

21942194
static zend_always_inline bool zend_parse_arg_bool_ex(const zval *arg, bool *dest, bool *is_null, bool check_null, uint32_t arg_num, bool frameless)
@@ -2290,10 +2290,16 @@ static zend_always_inline bool zend_parse_arg_str_ex(zval *arg, zend_string **de
22902290
} else if (check_null && Z_TYPE_P(arg) == IS_NULL) {
22912291
*dest = NULL;
22922292
} else {
2293+
zend_string *str;
22932294
if (frameless) {
2294-
return zend_flf_parse_arg_str_slow(arg, dest, arg_num);
2295+
str = zend_flf_parse_arg_str_slow(arg, arg_num);
22952296
} else {
2296-
return zend_parse_arg_str_slow(arg, dest, arg_num);
2297+
str = zend_parse_arg_str_slow(arg, arg_num);
2298+
}
2299+
if (str) {
2300+
*dest = str;
2301+
} else {
2302+
return 0;
22972303
}
22982304
}
22992305
return 1;
@@ -2527,7 +2533,12 @@ static zend_always_inline bool zend_parse_arg_array_ht_or_str(
25272533
*dest_str = NULL;
25282534
} else {
25292535
*dest_ht = NULL;
2530-
return zend_parse_arg_str_slow(arg, dest_str, arg_num);
2536+
zend_string *str = zend_parse_arg_str_slow(arg, arg_num);
2537+
if (str) {
2538+
*dest_str = str;
2539+
} else {
2540+
return 0;
2541+
}
25312542
}
25322543
return 1;
25332544
}

Zend/zend_execute.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,7 +725,6 @@ static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg)
725725
{
726726
zend_long lval;
727727
double dval;
728-
zend_string *str;
729728
bool bval;
730729

731730
/* Type preference order: int -> float -> string -> bool */
@@ -757,7 +756,7 @@ static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg)
757756
ZVAL_DOUBLE(arg, dval);
758757
return 1;
759758
}
760-
if ((type_mask & MAY_BE_STRING) && zend_parse_arg_str_weak(arg, &str, 0)) {
759+
if ((type_mask & MAY_BE_STRING) && zend_parse_arg_str_weak(arg, 0)) {
761760
/* on success "arg" is converted to IS_STRING */
762761
return 1;
763762
}

Zend/zend_frameless_function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
dest_ht = NULL; \
6666
ZVAL_COPY(&str_tmp, arg ## arg_num); \
6767
arg ## arg_num = &str_tmp; \
68-
if (!zend_flf_parse_arg_str_slow(arg ## arg_num, &dest_str, arg_num)) { \
68+
if (!(dest_str = zend_flf_parse_arg_str_slow(arg ## arg_num, arg_num))) { \
6969
zend_wrong_parameter_type_error(arg_num, Z_EXPECTED_ARRAY_OR_STRING, arg ## arg_num); \
7070
goto flf_clean; \
7171
} \

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8718,7 +8718,7 @@ ZEND_VM_COLD_CONST_HANDLER(121, ZEND_STRLEN, CONST|TMPVAR|CV, ANY)
87188718
}
87198719

87208720
ZVAL_COPY(&tmp, value);
8721-
if (zend_parse_arg_str_weak(&tmp, &str, 1)) {
8721+
if ((str = zend_parse_arg_str_weak(&tmp, 1))) {
87228722
ZVAL_LONG(EX_VAR(opline->result.var), ZSTR_LEN(str));
87238723
zval_ptr_dtor(&tmp);
87248724
break;

Zend/zend_vm_execute.h

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)