mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Clarify that the get_properties handler is required
Some places were checking for non-null get_properties, some weren't. Make it clear that the handler is required and such checks are not necessary.
This commit is contained in:
parent
74d138e4a3
commit
f48ee1ff58
6 changed files with 8 additions and 17 deletions
|
@ -389,7 +389,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
|
|||
break;
|
||||
case IS_OBJECT:
|
||||
{
|
||||
HashTable *properties = NULL;
|
||||
HashTable *properties;
|
||||
zend_string *class_name = Z_OBJ_HANDLER_P(expr, get_class_name)(Z_OBJ_P(expr));
|
||||
zend_printf("%s Object (", ZSTR_VAL(class_name));
|
||||
zend_string_release_ex(class_name, 0);
|
||||
|
@ -399,9 +399,7 @@ ZEND_API void zend_print_flat_zval_r(zval *expr) /* {{{ */
|
|||
return;
|
||||
}
|
||||
|
||||
if (Z_OBJ_HANDLER_P(expr, get_properties)) {
|
||||
properties = Z_OBJPROP_P(expr);
|
||||
}
|
||||
properties = Z_OBJPROP_P(expr);
|
||||
if (properties) {
|
||||
Z_PROTECT_RECURSION_P(expr);
|
||||
print_flat_hash(properties);
|
||||
|
|
|
@ -1174,12 +1174,7 @@ ZEND_FUNCTION(get_object_vars)
|
|||
Z_PARAM_OBJECT(obj)
|
||||
ZEND_PARSE_PARAMETERS_END();
|
||||
|
||||
if (Z_OBJ_HT_P(obj)->get_properties == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
properties = Z_OBJ_HT_P(obj)->get_properties(obj);
|
||||
|
||||
if (properties == NULL) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
|
|
@ -145,9 +145,7 @@ ZEND_API HashTable *zend_std_get_debug_info(zval *object, int *is_temp) /* {{{ *
|
|||
|
||||
if (!ce->__debugInfo) {
|
||||
*is_temp = 0;
|
||||
return Z_OBJ_HANDLER_P(object, get_properties)
|
||||
? Z_OBJ_HANDLER_P(object, get_properties)(object)
|
||||
: NULL;
|
||||
return Z_OBJ_HANDLER_P(object, get_properties)(object);
|
||||
}
|
||||
|
||||
zend_call_method_with_0_params(object, ce, &ce->__debugInfo, ZEND_DEBUGINFO_FUNC_NAME, &retval);
|
||||
|
|
|
@ -147,7 +147,7 @@ struct _zend_object_handlers {
|
|||
zend_object_unset_property_t unset_property;
|
||||
zend_object_has_dimension_t has_dimension;
|
||||
zend_object_unset_dimension_t unset_dimension;
|
||||
zend_object_get_properties_t get_properties;
|
||||
zend_object_get_properties_t get_properties; /* required */
|
||||
zend_object_get_method_t get_method;
|
||||
zend_object_call_method_t call_method;
|
||||
zend_object_get_constructor_t get_constructor;
|
||||
|
|
|
@ -670,7 +670,7 @@ static zend_always_inline uint32_t zval_gc_info(uint32_t gc_type_info) {
|
|||
#define Z_OBJPROP(zval) Z_OBJ_HT((zval))->get_properties(&(zval))
|
||||
#define Z_OBJPROP_P(zval_p) Z_OBJPROP(*(zval_p))
|
||||
|
||||
#define Z_OBJDEBUG(zval,tmp) (Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&tmp):(tmp=0,Z_OBJ_HANDLER((zval),get_properties)?Z_OBJPROP(zval):NULL))
|
||||
#define Z_OBJDEBUG(zval,tmp) (Z_OBJ_HANDLER((zval),get_debug_info)?Z_OBJ_HANDLER((zval),get_debug_info)(&(zval),&tmp):(tmp=0,Z_OBJPROP(zval)))
|
||||
#define Z_OBJDEBUG_P(zval_p,tmp) Z_OBJDEBUG(*(zval_p), tmp)
|
||||
|
||||
#define Z_RES(zval) (zval).value.res
|
||||
|
|
|
@ -434,7 +434,7 @@ static void _class_string(smart_str *str, zend_class_entry *ce, zval *obj, char
|
|||
}
|
||||
smart_str_append_printf(str, "%s }\n", indent);
|
||||
|
||||
if (obj && Z_TYPE_P(obj) == IS_OBJECT && Z_OBJ_HT_P(obj)->get_properties) {
|
||||
if (obj && Z_TYPE_P(obj) == IS_OBJECT) {
|
||||
HashTable *properties = Z_OBJ_HT_P(obj)->get_properties(obj);
|
||||
zend_string *prop_name;
|
||||
smart_str prop_str = {0};
|
||||
|
@ -4322,7 +4322,7 @@ ZEND_METHOD(reflection_class, getProperties)
|
|||
_addproperty(prop_info, key, ce, return_value, filter);
|
||||
} ZEND_HASH_FOREACH_END();
|
||||
|
||||
if (Z_TYPE(intern->obj) != IS_UNDEF && (filter & ZEND_ACC_PUBLIC) != 0 && Z_OBJ_HT(intern->obj)->get_properties) {
|
||||
if (Z_TYPE(intern->obj) != IS_UNDEF && (filter & ZEND_ACC_PUBLIC) != 0) {
|
||||
HashTable *properties = Z_OBJ_HT(intern->obj)->get_properties(&intern->obj);
|
||||
zval *prop;
|
||||
ZEND_HASH_FOREACH_STR_KEY_VAL(properties, key, prop) {
|
||||
|
@ -5227,7 +5227,7 @@ ZEND_METHOD(reflection_property, __construct)
|
|||
|| ((property_info->flags & ZEND_ACC_PRIVATE)
|
||||
&& property_info->ce != ce)) {
|
||||
/* Check for dynamic properties */
|
||||
if (property_info == NULL && Z_TYPE_P(classname) == IS_OBJECT && Z_OBJ_HT_P(classname)->get_properties) {
|
||||
if (property_info == NULL && Z_TYPE_P(classname) == IS_OBJECT) {
|
||||
if (zend_hash_exists(Z_OBJ_HT_P(classname)->get_properties(classname), name)) {
|
||||
dynam_prop = 1;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue