@@ -110,9 +110,29 @@ typedef zend_array *(*zend_object_get_properties_for_t)(zend_object *object, zen
110
110
typedef zend_function * (* zend_object_get_method_t )(zend_object * * object , zend_string * method , const zval * key );
111
111
typedef zend_function * (* zend_object_get_constructor_t )(zend_object * object );
112
112
113
- /* Object maintenance/destruction */
114
- typedef void (* zend_object_dtor_obj_t )(zend_object * object );
113
+ /* free_obj should release any resources the object holds, without freeing the
114
+ * object structure itself. The object does not need to be in a valid state after
115
+ * free_obj finishes running.
116
+ *
117
+ * free_obj will always be invoked, even if the object leaks or a fatal error
118
+ * occurs. However, during shutdown it may be called once the executor is no
119
+ * longer active, in which case execution of user code may be skipped.
120
+ */
115
121
typedef void (* zend_object_free_obj_t )(zend_object * object );
122
+
123
+ /* dtor_obj is called before free_obj. The object must remain in a valid state
124
+ * after dtor_obj finishes running. Unlike free_obj, it is run prior to
125
+ * deactivation of the executor during shutdown, which allows user code to run.
126
+ *
127
+ * This handler is not guaranteed to be called (e.g. on fatal error), and as
128
+ * such should not be used to release resources or deallocate memory. Furthermore,
129
+ * releasing resources in this handler can break detection of memory leaks, as
130
+ * cycles may be broken early.
131
+ *
132
+ * dtor_obj should be used *only* to call user destruction hooks, such as __destruct.
133
+ */
134
+ typedef void (* zend_object_dtor_obj_t )(zend_object * object );
135
+
116
136
typedef zend_object * (* zend_object_clone_obj_t )(zend_object * object );
117
137
118
138
/* Get class name for display in var_dump and other debugging functions.
0 commit comments