Skip to content

Commit f373a84

Browse files
committed
Fix destination
1 parent d8e33aa commit f373a84

File tree

2 files changed

+15
-25
lines changed

2 files changed

+15
-25
lines changed

Zend/zend_API.h

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1397,19 +1397,19 @@ ZEND_API ZEND_COLD void ZEND_FASTCALL zend_argument_value_error(uint32_t arg_num
13971397
#define Z_PARAM_CLASS(dest) \
13981398
Z_PARAM_CLASS_EX(dest, 0, 0)
13991399

1400-
#define Z_PARAM_CLASS_NAME_OR_OBJ_EX(dest_str, dest_object, allow_null) \
1400+
#define Z_PARAM_CLASS_NAME_OR_OBJ_EX(dest, allow_null) \
14011401
Z_PARAM_PROLOGUE(0, 0); \
1402-
if (UNEXPECTED(!zend_parse_arg_class_name_or_obj(_arg, &dest_str, &dest_object, _i, allow_null))) { \
1402+
if (UNEXPECTED(!zend_parse_arg_class_name_or_obj(_arg, &dest, _i, allow_null))) { \
14031403
_expected_type = allow_null ? Z_EXPECTED_CLASS_NAME_OR_OBJECT_OR_NULL : Z_EXPECTED_CLASS_NAME_OR_OBJECT; \
14041404
_error_code = ZPP_ERROR_WRONG_ARG; \
14051405
break; \
14061406
}
14071407

1408-
#define Z_PARAM_CLASS_NAME_OR_OBJ(dest_str, dest_object) \
1409-
Z_PARAM_CLASS_NAME_OR_OBJ_EX(dest_str, dest_object, 0);
1408+
#define Z_PARAM_CLASS_NAME_OR_OBJ(dest) \
1409+
Z_PARAM_CLASS_NAME_OR_OBJ_EX(dest, 0);
14101410

1411-
#define Z_PARAM_CLASS_NAME_OR_OBJ_OR_NULL(dest_str, dest_object) \
1412-
Z_PARAM_CLASS_NAME_OR_OBJ_EX(dest_str, dest_object, 1);
1411+
#define Z_PARAM_CLASS_NAME_OR_OBJ_OR_NULL(dest) \
1412+
Z_PARAM_CLASS_NAME_OR_OBJ_EX(dest, 1);
14131413

14141414
/* old "d" */
14151415
#define Z_PARAM_DOUBLE_EX2(dest, is_null, check_null, deref, separate) \
@@ -1955,22 +1955,18 @@ static zend_always_inline int zend_parse_arg_str_or_long(zval *arg, zend_string
19551955
}
19561956

19571957
static zend_always_inline int zend_parse_arg_class_name_or_obj(
1958-
zval *arg, zend_string **dest_str, zend_object **dest_object, int num, int allow_null
1958+
zval *arg, zend_class_entry **destination, int num, int allow_null
19591959
) {
1960-
zend_class_entry *class_entry;
1960+
if (EXPECTED(Z_TYPE_P(arg) == IS_STRING)) {
1961+
*destination = zend_lookup_class(Z_STR_P(arg));
19611962

1962-
if (EXPECTED(Z_TYPE_P(arg) == IS_STRING) && (class_entry = zend_lookup_class(Z_STR_P(arg)))) {
1963-
*dest_str = class_entry->name;
1964-
*dest_object = NULL;
1963+
return *destination != NULL;
19651964
} else if (EXPECTED(Z_TYPE_P(arg) == IS_OBJECT)) {
1966-
*dest_str = NULL;
1967-
*dest_object = Z_OBJ_P(arg);
1965+
*destination = Z_OBJ_P(arg)->ce;
19681966
} else if (allow_null && EXPECTED(Z_TYPE_P(arg) == IS_NULL)) {
1969-
*dest_str = NULL;
1970-
*dest_object = NULL;
1967+
*destination = NULL;
19711968
} else {
1972-
*dest_str = NULL;
1973-
*dest_object = NULL;
1969+
*destination = NULL;
19741970
return 0;
19751971
}
19761972

Zend/zend_builtin_functions.c

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -637,20 +637,14 @@ ZEND_FUNCTION(get_called_class)
637637
Retrieves the parent class name for object or class or current scope or false if not in a scope. */
638638
ZEND_FUNCTION(get_parent_class)
639639
{
640-
zend_string *str = NULL;
641-
zend_object *object = NULL;
642640
zend_class_entry *ce = NULL;
643641

644642
ZEND_PARSE_PARAMETERS_START(0, 1)
645643
Z_PARAM_OPTIONAL
646-
Z_PARAM_CLASS_NAME_OR_OBJ(str, object)
644+
Z_PARAM_CLASS_NAME_OR_OBJ(ce)
647645
ZEND_PARSE_PARAMETERS_END();
648646

649-
if (object) {
650-
ce = object->ce;
651-
} else if (str) {
652-
ce = zend_lookup_class(str);
653-
} else {
647+
if (!ce) {
654648
ce = zend_get_executed_scope();
655649
}
656650

0 commit comments

Comments
 (0)