mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Call cast_object handler from get_properties_for
Fixes GH-11547 Closes GH-11583
This commit is contained in:
parent
127ad70782
commit
4182813ebf
4 changed files with 17 additions and 0 deletions
|
@ -70,6 +70,8 @@ PHP 8.3 INTERNALS UPGRADE NOTES
|
|||
* _php_stream_dirent now has an extra d_type field that is used to store the
|
||||
directory entry type. This can be used to avoid additional stat calls for
|
||||
types when the type is already known.
|
||||
* zend_std_get_properties_for now calls the cast_object handler when casting
|
||||
objects to arrays.
|
||||
|
||||
========================
|
||||
2. Build system changes
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue