Skip to content

Commit f7291a2

Browse files
committed
Move to a set of handlers on the CE
1 parent 31d625d commit f7291a2

27 files changed

+597
-430
lines changed

Zend/tests/offsets/ArrayObject_container_offset_behaviour.phpt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,12 @@ Cannot unset offset of type %s on ArrayObject
138138
Nested read:
139139
Cannot access offset of type %s on ArrayObject
140140
Nested write:
141+
142+
Notice: Indirect modification of overloaded element of ArrayObject has no effect in %s on line 69
141143
Cannot access offset of type %s on ArrayObject
142144
Nested Read-Write:
145+
146+
Notice: Indirect modification of overloaded element of ArrayObject has no effect in %s on line 76
143147
Cannot access offset of type %s on ArrayObject
144148
Nested isset():
145149
Cannot access offset of type %s in isset or empty
@@ -150,7 +154,7 @@ Cannot access offset of type %s in isset or empty
150154
Nested unset():
151155
152156
Notice: Indirect modification of overloaded element of ArrayObject has no effect in %s on line 102
153-
Cannot unset offset of type %s on ArrayObject
157+
Cannot access offset of type %s on ArrayObject
154158
155159
OUTPUT;
156160

Zend/tests/offsets/internal_handlers.phpt

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -194,63 +194,63 @@ exportObject($o);
194194
?>
195195
--EXPECTF--
196196
read op
197-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_R, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
197+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
198198
write op
199199
DimensionHandlersNoArrayAccess, read: false, write: true, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
200200
read-write op
201-
DimensionHandlersNoArrayAccess, read: true, write: true, has: false, unset: false, readType: BP_VAR_R, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
201+
DimensionHandlersNoArrayAccess, read: true, write: true, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
202202
isset op
203-
DimensionHandlersNoArrayAccess, read: false, write: false, has: true, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: 0, offset: 'foo'
203+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
204204
empty op
205-
DimensionHandlersNoArrayAccess, read: false, write: false, has: true, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: 1, offset: 'foo'
205+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
206206
null coalescing op
207-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_IS, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
207+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
208208
appending op
209-
DimensionHandlersNoArrayAccess, read: false, write: true, has: false, unset: false, readType: uninitialized, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized
209+
DimensionHandlersNoArrayAccess, read: false, write: false, has: false, unset: false, readType: uninitialized, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized
210210
unset op
211211
DimensionHandlersNoArrayAccess, read: false, write: false, has: false, unset: true, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
212212
nested read
213213

214214
Warning: Trying to access array offset on true in %s on line %d
215-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_R, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
215+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
216216
nested write
217217

218218
Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d
219219
Error: Cannot use a scalar value as an array
220-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
220+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
221221
nested write: appending then write
222222

223223
Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d
224224
Error: Cannot use a scalar value as an array
225-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized
225+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized
226226
nested read-write
227227

228228
Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d
229229
Error: Cannot use a scalar value as an array
230-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_RW, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
230+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
231231
nested read-write: appending then write
232232

233233
Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d
234234
Error: Cannot use a scalar value as an array
235-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_RW, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized
235+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized
236236
nested isset
237-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_IS, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
237+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
238238
nested empty
239-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_IS, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
239+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
240240
nested null coalescing
241-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_IS, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
241+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
242242
nested appending
243243

244244
Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d
245245
Error: Cannot use a scalar value as an array
246-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
246+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
247247
nested appending: appending then append
248248

249249
Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d
250250
Error: Cannot use a scalar value as an array
251-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_W, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized
251+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: false, checkEmpty: uninitialized, offset: uninitialized
252252
nested unset
253253

254254
Notice: Indirect modification of overloaded element of DimensionHandlersNoArrayAccess has no effect in %s on line %d
255255
Error: Cannot unset offset in a non-array variable
256-
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: BP_VAR_UNSET, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'
256+
DimensionHandlersNoArrayAccess, read: true, write: false, has: false, unset: false, readType: uninitialized, hasOffset: true, checkEmpty: uninitialized, offset: 'foo'

Zend/zend.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
#include "zend_gc.h"
3636
#include "zend_variables.h"
3737
#include "zend_iterators.h"
38+
#include "zend_dimension_handlers.h"
3839
#include "zend_stream.h"
3940
#include "zend_smart_str_public.h"
4041
#include "zend_smart_string_public.h"
@@ -202,6 +203,9 @@ struct _zend_class_entry {
202203
int (*serialize)(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data);
203204
int (*unserialize)(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data);
204205

206+
/* dimension handler callbacks */
207+
zend_class_dimensions_functions *dimension_handlers;
208+
205209
uint32_t num_interfaces;
206210
uint32_t num_traits;
207211

Zend/zend_compile.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,6 +2034,7 @@ ZEND_API void zend_initialize_class_data(zend_class_entry *ce, bool nullify_hand
20342034
ce->trait_precedences = NULL;
20352035
ce->serialize = NULL;
20362036
ce->unserialize = NULL;
2037+
ce->dimension_handlers = NULL;
20372038
if (ce->type == ZEND_INTERNAL_CLASS) {
20382039
ce->info.internal.module = NULL;
20392040
ce->info.internal.builtin_functions = NULL;

Zend/zend_user_dimension.h renamed to Zend/zend_dimension_handlers.h

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,22 @@
1616
+----------------------------------------------------------------------+
1717
*/
1818

19-
#include "zend_types.h"
20-
#include "zend_compile.h"
19+
/* This really should not be needed... */
20+
#ifndef ZEND_DIMENSION_HANDLERS_H
21+
#define ZEND_DIMENSION_HANDLERS_H
2122

22-
/*
23+
//BEGIN_EXTERN_C()
24+
25+
typedef struct _zend_class_dimensions_functions {
26+
/* rv is a slot provided by the callee that is returned */
27+
zval *(*/* const */ read_dimension)(zend_object *object, zval *offset, zval *rv);
28+
/* For isset() rv is NULL, for null coalesce and empty() rv is a slot provided by the callee */
29+
zval *(*/* const */ has_dimension)(zend_object *object, zval *offset, zval *rv);
30+
void (*/* const */ write_dimension)(zend_object *object, zval *offset, zval *value);
31+
/* rv is a slot provided by the callee that is returned */
32+
zval *(*/* const */ append_dimension)(zend_object *object, zval *value, zval *rv);
33+
void (*/* const */ unset_dimension)(zend_object *object, zval *offset);
34+
} zend_class_dimensions_functions;
2335

2436
typedef struct _zend_class_arrayaccess_funcs {
2537
zend_function *zf_offsetget;
@@ -28,14 +40,4 @@ typedef struct _zend_class_arrayaccess_funcs {
2840
zend_function *zf_offsetunset;
2941
} zend_class_arrayaccess_funcs;
3042

31-
*/
32-
33-
BEGIN_EXTERN_C()
34-
/* rv is a slot provided by the callee that is returned */
35-
ZEND_API zval *zend_user_class_read_dimension(zend_object *object, zval *offset, zval *rv);
36-
/* For isset() rv is NULL, for null coalesce and empty() rv is a slot provided by the callee */
37-
ZEND_API zval *zend_user_class_has_dimension(zend_object *object, zval *offset, zval *rv);
38-
ZEND_API void zend_user_class_write_dimension(zend_object *object, zval *offset, zval *value);
39-
ZEND_API zval *zend_user_class_append_dimension(zend_object *object, zval *value, zval *rv);
40-
ZEND_API void zend_user_class_unset_dimension(zend_object *object, zval *offset);
41-
END_EXTERN_C()
43+
#endif /* ZEND_DIMENSION_HANDLERS_H */

0 commit comments

Comments
 (0)