Skip to content

Commit 5c689b4

Browse files
committed
Apply review comments
1 parent 44a5e26 commit 5c689b4

File tree

5 files changed

+26
-31
lines changed

5 files changed

+26
-31
lines changed

Zend/zend_API.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -511,20 +511,20 @@ static ZEND_COLD bool zend_null_arg_deprecated(const char *fallback_type, uint32
511511

512512
ZEND_API zpp_parse_bool_status ZEND_FASTCALL zend_parse_arg_bool_weak(const zval *arg, uint32_t arg_num) /* {{{ */
513513
{
514-
if (EXPECTED(Z_TYPE_P(arg) <= IS_STRING)) {
515-
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("bool", arg_num)) {
516-
return ZPP_PARSE_ERROR;
517-
}
518-
return zend_is_true(arg);
514+
if (UNEXPECTED(Z_TYPE_P(arg) > IS_STRING)) {
515+
return ZPP_PARSE_BOOL_STATUS_ERROR;
516+
}
517+
if (UNEXPECTED(Z_TYPE_P(arg) == IS_NULL) && !zend_null_arg_deprecated("bool", arg_num)) {
518+
return ZPP_PARSE_BOOL_STATUS_ERROR;
519519
}
520-
return ZPP_PARSE_ERROR;
520+
return zend_is_true(arg);
521521
}
522522
/* }}} */
523523

524524
ZEND_API zpp_parse_bool_status ZEND_FASTCALL zend_parse_arg_bool_slow(const zval *arg, uint32_t arg_num) /* {{{ */
525525
{
526526
if (UNEXPECTED(ZEND_ARG_USES_STRICT_TYPES())) {
527-
return ZPP_PARSE_ERROR;
527+
return ZPP_PARSE_BOOL_STATUS_ERROR;
528528
}
529529
return zend_parse_arg_bool_weak(arg, arg_num);
530530
}
@@ -533,7 +533,7 @@ ZEND_API zpp_parse_bool_status ZEND_FASTCALL zend_parse_arg_bool_slow(const zval
533533
ZEND_API zpp_parse_bool_status ZEND_FASTCALL zend_flf_parse_arg_bool_slow(const zval *arg, uint32_t arg_num)
534534
{
535535
if (UNEXPECTED(ZEND_FLF_ARG_USES_STRICT_TYPES())) {
536-
return ZPP_PARSE_ERROR;
536+
return ZPP_PARSE_BOOL_STATUS_ERROR;
537537
}
538538
return zend_parse_arg_bool_weak(arg, arg_num);
539539
}

Zend/zend_API.h

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2173,10 +2173,10 @@ ZEND_API ZEND_COLD void zend_class_redeclaration_error_ex(int type, zend_string
21732173

21742174
/* Inlined implementations shared by new and old parameter parsing APIs */
21752175

2176-
typedef enum ZPP_PARSE_BOOL_STATUS {
2177-
ZPP_PARSE_AS_FALSE = 0,
2178-
ZPP_PARSE_AS_TRUE = 1,
2179-
ZPP_PARSE_ERROR = 2,
2176+
typedef enum zpp_parse_bool_status {
2177+
ZPP_PARSE_BOOL_STATUS_FALSE = 0,
2178+
ZPP_PARSE_BOOL_STATUS_TRUE = 1,
2179+
ZPP_PARSE_BOOL_STATUS_ERROR = 2,
21802180
} zpp_parse_bool_status;
21812181

21822182
ZEND_API bool ZEND_FASTCALL zend_parse_arg_class(zval *arg, zend_class_entry **pce, uint32_t num, bool check_null);
@@ -2215,7 +2215,7 @@ static zend_always_inline bool zend_parse_arg_bool_ex(const zval *arg, bool *des
22152215
} else {
22162216
result = zend_parse_arg_bool_slow(arg, arg_num);
22172217
}
2218-
if (UNEXPECTED(result == ZPP_PARSE_ERROR)) {
2218+
if (UNEXPECTED(result == ZPP_PARSE_BOOL_STATUS_ERROR)) {
22192219
return false;
22202220
}
22212221
*dest = result;
@@ -2301,19 +2301,14 @@ static zend_always_inline bool zend_parse_arg_str_ex(zval *arg, zend_string **de
23012301
} else if (check_null && Z_TYPE_P(arg) == IS_NULL) {
23022302
*dest = NULL;
23032303
} else {
2304-
zend_string *str;
23052304
if (frameless) {
2306-
str = zend_flf_parse_arg_str_slow(arg, arg_num);
2305+
*dest = zend_flf_parse_arg_str_slow(arg, arg_num);
23072306
} else {
2308-
str = zend_parse_arg_str_slow(arg, arg_num);
2309-
}
2310-
if (str) {
2311-
*dest = str;
2312-
} else {
2313-
return 0;
2307+
*dest = zend_parse_arg_str_slow(arg, arg_num);
23142308
}
2309+
return *dest != NULL;
23152310
}
2316-
return 1;
2311+
return true;
23172312
}
23182313

23192314
static zend_always_inline bool zend_parse_arg_str(zval *arg, zend_string **dest, bool check_null, uint32_t arg_num)

Zend/zend_execute.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -772,7 +772,7 @@ static bool zend_verify_weak_scalar_type_hint(uint32_t type_mask, zval *arg)
772772
}
773773
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL) {
774774
zpp_parse_bool_status bval = zend_parse_arg_bool_weak(arg, 0);
775-
if (UNEXPECTED(bval == ZPP_PARSE_ERROR)) {
775+
if (UNEXPECTED(bval == ZPP_PARSE_BOOL_STATUS_ERROR)) {
776776
return false;
777777
}
778778
zval_ptr_dtor(arg);
@@ -810,7 +810,7 @@ static bool zend_verify_weak_scalar_type_hint_no_sideeffect(uint32_t type_mask,
810810
if ((type_mask & MAY_BE_STRING) && can_convert_to_string(arg)) {
811811
return true;
812812
}
813-
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, (uint32_t)-1) != ZPP_PARSE_ERROR) {
813+
if ((type_mask & MAY_BE_BOOL) == MAY_BE_BOOL && zend_parse_arg_bool_weak(arg, (uint32_t)-1) != ZPP_PARSE_BOOL_STATUS_ERROR) {
814814
return true;
815815
}
816816
return false;

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8823,8 +8823,8 @@ ZEND_VM_COLD_CONST_HANDLER(121, ZEND_STRLEN, CONST|TMP|CV, ANY)
88238823
strict = EX_USES_STRICT_TYPES();
88248824
do {
88258825
if (EXPECTED(!strict)) {
8826-
zval tmp;
88278826
zend_string *str;
8827+
zval tmp;
88288828

88298829
if (UNEXPECTED(Z_TYPE_P(value) == IS_NULL)) {
88308830
zend_error(E_DEPRECATED,

Zend/zend_vm_execute.h

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

0 commit comments

Comments
 (0)