Skip to content

Call cast_object handler from get_properties_for #11583

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Zend/zend_object_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -1975,6 +1975,16 @@ ZEND_API HashTable *zend_std_get_properties_for(zend_object *obj, zend_prop_purp
}
ZEND_FALLTHROUGH;
case ZEND_PROP_PURPOSE_ARRAY_CAST:
if (obj->handlers->cast_object != std_object_handlers.cast_object) {
zval result;
if (obj->handlers->cast_object(obj, &result, IS_ARRAY) == SUCCESS) {
return Z_ARRVAL(result);
}
if (EG(exception)) {
return NULL;
}
}
ZEND_FALLTHROUGH;
case ZEND_PROP_PURPOSE_SERIALIZE:
case ZEND_PROP_PURPOSE_VAR_EXPORT:
case ZEND_PROP_PURPOSE_JSON:
Expand Down
4 changes: 4 additions & 0 deletions ext/com_dotnet/com_handlers.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ static int com_objects_compare(zval *object1, zval *object2)

static zend_result com_object_cast(zend_object *readobj, zval *writeobj, int type)
{
if (type == IS_ARRAY) {
return FAILURE;
}

php_com_dotnet_object *obj;
VARIANT v;
VARTYPE vt = VT_EMPTY;
Expand Down
1 change: 1 addition & 0 deletions ext/simplexml/simplexml.c
Original file line number Diff line number Diff line change
Expand Up @@ -1819,6 +1819,7 @@ static zend_result cast_object(zval *object, int type, char *contents)
convert_scalar_to_number(object);
break;
default:
zval_ptr_dtor_nogc(object);
return FAILURE;
}
return SUCCESS;
Expand Down