Skip to content

Commit 7d3215d

Browse files
author
Andi Gutmans
committed
- Add comments to read/write property/dimension for extension authors
1 parent 229aa63 commit 7d3215d

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Zend/zend_object_handlers.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,29 @@
2424

2525
union _zend_function;
2626

27+
/* The following rule applies to read_property() and read_dimension() implementations:
28+
If you return a zval which is not otherwise referenced by the extension or the engine's
29+
symbol table, its reference count should be 0.
30+
*/
2731
/* Used to fetch property from the object, read-only */
2832
typedef zval *(*zend_object_read_property_t)(zval *object, zval *member, zend_bool silent TSRMLS_DC);
2933

3034
/* Used to fetch dimension from the object, read-only */
3135
typedef zval *(*zend_object_read_dimension_t)(zval *object, zval *offset, int type TSRMLS_DC);
3236

37+
38+
/* The following rule applies to write_property() and write_dimension() implementations:
39+
If you receive a value zval in write_property/write_dimension, you may only modify it if
40+
its reference count is 1. Otherwise, you must create a copy of that zval before making
41+
any changes. You should NOT modify the reference count of the value passed to you.
42+
*/
3343
/* Used to set property of the object */
3444
typedef void (*zend_object_write_property_t)(zval *object, zval *member, zval *value TSRMLS_DC);
3545

3646
/* Used to set dimension of the object */
3747
typedef void (*zend_object_write_dimension_t)(zval *object, zval *offset, zval *value TSRMLS_DC);
3848

49+
3950
/* Used to create pointer to the property of the object, for future direct r/w access */
4051
typedef zval **(*zend_object_get_property_ptr_ptr_t)(zval *object, zval *member TSRMLS_DC);
4152

0 commit comments

Comments
 (0)