xref: /PHP-7.2/Zend/zend_interfaces.c (revision 7a7ec01a)
1 /*
2    +----------------------------------------------------------------------+
3    | Zend Engine                                                          |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1998-2018 Zend Technologies Ltd. (http://www.zend.com) |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 2.00 of the Zend license,     |
8    | that is bundled with this package in the file LICENSE, and is        |
9    | available through the world-wide-web at the following url:           |
10    | http://www.zend.com/license/2_00.txt.                                |
11    | If you did not receive a copy of the Zend license and are unable to  |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@zend.com so we can mail you a copy immediately.              |
14    +----------------------------------------------------------------------+
15    | Authors: Marcus Boerger <helly@php.net>                              |
16    +----------------------------------------------------------------------+
17 */
18 
19 /* $Id$ */
20 
21 #include "zend.h"
22 #include "zend_API.h"
23 #include "zend_interfaces.h"
24 #include "zend_exceptions.h"
25 
26 ZEND_API zend_class_entry *zend_ce_traversable;
27 ZEND_API zend_class_entry *zend_ce_aggregate;
28 ZEND_API zend_class_entry *zend_ce_iterator;
29 ZEND_API zend_class_entry *zend_ce_arrayaccess;
30 ZEND_API zend_class_entry *zend_ce_serializable;
31 ZEND_API zend_class_entry *zend_ce_countable;
32 
33 /* {{{ zend_call_method
34  Only returns the returned zval if retval_ptr != NULL */
zend_call_method(zval * object,zend_class_entry * obj_ce,zend_function ** fn_proxy,const char * function_name,size_t function_name_len,zval * retval_ptr,int param_count,zval * arg1,zval * arg2)35 ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_function **fn_proxy, const char *function_name, size_t function_name_len, zval *retval_ptr, int param_count, zval* arg1, zval* arg2)
36 {
37 	int result;
38 	zend_fcall_info fci;
39 	zval retval;
40 	zval params[2];
41 
42 	if (param_count > 0) {
43 		ZVAL_COPY_VALUE(&params[0], arg1);
44 	}
45 	if (param_count > 1) {
46 		ZVAL_COPY_VALUE(&params[1], arg2);
47 	}
48 
49 	fci.size = sizeof(fci);
50 	fci.object = object ? Z_OBJ_P(object) : NULL;
51 	fci.retval = retval_ptr ? retval_ptr : &retval;
52 	fci.param_count = param_count;
53 	fci.params = params;
54 	fci.no_separation = 1;
55 
56 	if (!fn_proxy && !obj_ce) {
57 		/* no interest in caching and no information already present that is
58 		 * needed later inside zend_call_function. */
59 		ZVAL_STRINGL(&fci.function_name, function_name, function_name_len);
60 		result = zend_call_function(&fci, NULL);
61 		zval_ptr_dtor(&fci.function_name);
62 	} else {
63 		zend_fcall_info_cache fcic;
64 		ZVAL_UNDEF(&fci.function_name); /* Unused */
65 
66 		fcic.initialized = 1;
67 		if (!obj_ce) {
68 			obj_ce = object ? Z_OBJCE_P(object) : NULL;
69 		}
70 		if (!fn_proxy || !*fn_proxy) {
71 			HashTable *function_table = obj_ce ? &obj_ce->function_table : EG(function_table);
72 			fcic.function_handler = zend_hash_str_find_ptr(
73 				function_table, function_name, function_name_len);
74 			if (fcic.function_handler == NULL) {
75 				/* error at c-level */
76 				zend_error_noreturn(E_CORE_ERROR, "Couldn't find implementation for method %s%s%s", obj_ce ? ZSTR_VAL(obj_ce->name) : "", obj_ce ? "::" : "", function_name);
77 			}
78 			if (fn_proxy) {
79 				*fn_proxy = fcic.function_handler;
80 			}
81 		} else {
82 			fcic.function_handler = *fn_proxy;
83 		}
84 
85 		fcic.calling_scope = obj_ce;
86 		if (object) {
87 			fcic.called_scope = Z_OBJCE_P(object);
88 		} else {
89 			zend_class_entry *called_scope = zend_get_called_scope(EG(current_execute_data));
90 
91 			if (obj_ce &&
92 			    (!called_scope ||
93 			     !instanceof_function(called_scope, obj_ce))) {
94 				fcic.called_scope = obj_ce;
95 			} else {
96 				fcic.called_scope = called_scope;
97 			}
98 		}
99 		fcic.object = object ? Z_OBJ_P(object) : NULL;
100 		result = zend_call_function(&fci, &fcic);
101 	}
102 	if (result == FAILURE) {
103 		/* error at c-level */
104 		if (!obj_ce) {
105 			obj_ce = object ? Z_OBJCE_P(object) : NULL;
106 		}
107 		if (!EG(exception)) {
108 			zend_error_noreturn(E_CORE_ERROR, "Couldn't execute method %s%s%s", obj_ce ? ZSTR_VAL(obj_ce->name) : "", obj_ce ? "::" : "", function_name);
109 		}
110 	}
111 	if (!retval_ptr) {
112 		zval_ptr_dtor(&retval);
113 		return NULL;
114 	}
115 	return retval_ptr;
116 }
117 /* }}} */
118 
119 /* iterator interface, c-level functions used by engine */
120 
121 /* {{{ zend_user_it_new_iterator */
zend_user_it_new_iterator(zend_class_entry * ce,zval * object,zval * retval)122 ZEND_API void zend_user_it_new_iterator(zend_class_entry *ce, zval *object, zval *retval)
123 {
124 	zend_call_method_with_0_params(object, ce, &ce->iterator_funcs.zf_new_iterator, "getiterator", retval);
125 }
126 /* }}} */
127 
128 /* {{{ zend_user_it_invalidate_current */
zend_user_it_invalidate_current(zend_object_iterator * _iter)129 ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter)
130 {
131 	zend_user_iterator *iter = (zend_user_iterator*)_iter;
132 
133 	if (!Z_ISUNDEF(iter->value)) {
134 		zval_ptr_dtor(&iter->value);
135 		ZVAL_UNDEF(&iter->value);
136 	}
137 }
138 /* }}} */
139 
140 /* {{{ zend_user_it_dtor */
zend_user_it_dtor(zend_object_iterator * _iter)141 static void zend_user_it_dtor(zend_object_iterator *_iter)
142 {
143 	zend_user_iterator *iter = (zend_user_iterator*)_iter;
144 	zval *object = &iter->it.data;
145 
146 	zend_user_it_invalidate_current(_iter);
147 	zval_ptr_dtor(object);
148 }
149 /* }}} */
150 
151 /* {{{ zend_user_it_valid */
zend_user_it_valid(zend_object_iterator * _iter)152 ZEND_API int zend_user_it_valid(zend_object_iterator *_iter)
153 {
154 	if (_iter) {
155 		zend_user_iterator *iter = (zend_user_iterator*)_iter;
156 		zval *object = &iter->it.data;
157 		zval more;
158 		int result;
159 
160 		zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_valid, "valid", &more);
161 		if (Z_TYPE(more) != IS_UNDEF) {
162 			result = i_zend_is_true(&more);
163 			zval_ptr_dtor(&more);
164 			return result ? SUCCESS : FAILURE;
165 		}
166 	}
167 	return FAILURE;
168 }
169 /* }}} */
170 
171 /* {{{ zend_user_it_get_current_data */
zend_user_it_get_current_data(zend_object_iterator * _iter)172 ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter)
173 {
174 	zend_user_iterator *iter = (zend_user_iterator*)_iter;
175 	zval *object = &iter->it.data;
176 
177 	if (Z_ISUNDEF(iter->value)) {
178 		zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_current, "current", &iter->value);
179 	}
180 	return &iter->value;
181 }
182 /* }}} */
183 
184 /* {{{ zend_user_it_get_current_key */
zend_user_it_get_current_key(zend_object_iterator * _iter,zval * key)185 ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key)
186 {
187 	zend_user_iterator *iter = (zend_user_iterator*)_iter;
188 	zval *object = &iter->it.data;
189 	zval retval;
190 
191 	zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_key, "key", &retval);
192 
193 	if (Z_TYPE(retval) != IS_UNDEF) {
194 		ZVAL_ZVAL(key, &retval, 1, 1);
195 	} else {
196 		if (!EG(exception)) {
197 			zend_error(E_WARNING, "Nothing returned from %s::key()", ZSTR_VAL(iter->ce->name));
198 		}
199 
200 		ZVAL_LONG(key, 0);
201 	}
202 }
203 /* }}} */
204 
205 /* {{{ zend_user_it_move_forward */
zend_user_it_move_forward(zend_object_iterator * _iter)206 ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter)
207 {
208 	zend_user_iterator *iter = (zend_user_iterator*)_iter;
209 	zval *object = &iter->it.data;
210 
211 	zend_user_it_invalidate_current(_iter);
212 	zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_next, "next", NULL);
213 }
214 /* }}} */
215 
216 /* {{{ zend_user_it_rewind */
zend_user_it_rewind(zend_object_iterator * _iter)217 ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter)
218 {
219 	zend_user_iterator *iter = (zend_user_iterator*)_iter;
220 	zval *object = &iter->it.data;
221 
222 	zend_user_it_invalidate_current(_iter);
223 	zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_rewind, "rewind", NULL);
224 }
225 /* }}} */
226 
227 zend_object_iterator_funcs zend_interface_iterator_funcs_iterator = {
228 	zend_user_it_dtor,
229 	zend_user_it_valid,
230 	zend_user_it_get_current_data,
231 	zend_user_it_get_current_key,
232 	zend_user_it_move_forward,
233 	zend_user_it_rewind,
234 	zend_user_it_invalidate_current
235 };
236 
237 /* {{{ zend_user_it_get_iterator */
zend_user_it_get_iterator(zend_class_entry * ce,zval * object,int by_ref)238 static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zval *object, int by_ref)
239 {
240 	zend_user_iterator *iterator;
241 
242 	if (by_ref) {
243 		zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
244 		return NULL;
245 	}
246 
247 	iterator = emalloc(sizeof(zend_user_iterator));
248 
249 	zend_iterator_init((zend_object_iterator*)iterator);
250 
251 	ZVAL_COPY(&iterator->it.data, object);
252 	iterator->it.funcs = ce->iterator_funcs.funcs;
253 	iterator->ce = Z_OBJCE_P(object);
254 	ZVAL_UNDEF(&iterator->value);
255 	return (zend_object_iterator*)iterator;
256 }
257 /* }}} */
258 
259 /* {{{ zend_user_it_get_new_iterator */
zend_user_it_get_new_iterator(zend_class_entry * ce,zval * object,int by_ref)260 ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object, int by_ref)
261 {
262 	zval iterator;
263 	zend_object_iterator *new_iterator;
264 	zend_class_entry *ce_it;
265 
266 	zend_user_it_new_iterator(ce, object, &iterator);
267 	ce_it = (Z_TYPE(iterator) == IS_OBJECT) ? Z_OBJCE(iterator) : NULL;
268 
269 	if (!ce_it || !ce_it->get_iterator || (ce_it->get_iterator == zend_user_it_get_new_iterator && Z_OBJ(iterator) == Z_OBJ_P(object))) {
270 		if (!EG(exception)) {
271 			zend_throw_exception_ex(NULL, 0, "Objects returned by %s::getIterator() must be traversable or implement interface Iterator", ce ? ZSTR_VAL(ce->name) : ZSTR_VAL(Z_OBJCE_P(object)->name));
272 		}
273 		zval_ptr_dtor(&iterator);
274 		return NULL;
275 	}
276 
277 	new_iterator = ce_it->get_iterator(ce_it, &iterator, by_ref);
278 	zval_ptr_dtor(&iterator);
279 	return new_iterator;
280 }
281 /* }}} */
282 
283 /* {{{ zend_implement_traversable */
zend_implement_traversable(zend_class_entry * interface,zend_class_entry * class_type)284 static int zend_implement_traversable(zend_class_entry *interface, zend_class_entry *class_type)
285 {
286 	/* check that class_type is traversable at c-level or implements at least one of 'aggregate' and 'Iterator' */
287 	uint32_t i;
288 
289 	if (class_type->get_iterator || (class_type->parent && class_type->parent->get_iterator)) {
290 		return SUCCESS;
291 	}
292 	for (i = 0; i < class_type->num_interfaces; i++) {
293 		if (class_type->interfaces[i] == zend_ce_aggregate || class_type->interfaces[i] == zend_ce_iterator) {
294 			return SUCCESS;
295 		}
296 	}
297 	zend_error_noreturn(E_CORE_ERROR, "Class %s must implement interface %s as part of either %s or %s",
298 		ZSTR_VAL(class_type->name),
299 		ZSTR_VAL(zend_ce_traversable->name),
300 		ZSTR_VAL(zend_ce_iterator->name),
301 		ZSTR_VAL(zend_ce_aggregate->name));
302 	return FAILURE;
303 }
304 /* }}} */
305 
306 /* {{{ zend_implement_aggregate */
zend_implement_aggregate(zend_class_entry * interface,zend_class_entry * class_type)307 static int zend_implement_aggregate(zend_class_entry *interface, zend_class_entry *class_type)
308 {
309 	uint32_t i;
310 	int t = -1;
311 
312 	if (class_type->get_iterator) {
313 		if (class_type->type == ZEND_INTERNAL_CLASS) {
314 			/* inheritance ensures the class has necessary userland methods */
315 			return SUCCESS;
316 		} else if (class_type->get_iterator != zend_user_it_get_new_iterator) {
317 			/* c-level get_iterator cannot be changed (exception being only Traversable is implmented) */
318 			if (class_type->num_interfaces) {
319 				for (i = 0; i < class_type->num_interfaces; i++) {
320 					if (class_type->interfaces[i] == zend_ce_iterator) {
321 						zend_error_noreturn(E_ERROR, "Class %s cannot implement both %s and %s at the same time",
322 									ZSTR_VAL(class_type->name),
323 									ZSTR_VAL(interface->name),
324 									ZSTR_VAL(zend_ce_iterator->name));
325 						return FAILURE;
326 					}
327 					if (class_type->interfaces[i] == zend_ce_traversable) {
328 						t = i;
329 					}
330 				}
331 			}
332 			if (t == -1) {
333 				return FAILURE;
334 			}
335 		}
336 	}
337 	class_type->iterator_funcs.zf_new_iterator = NULL;
338 	class_type->get_iterator = zend_user_it_get_new_iterator;
339 	return SUCCESS;
340 }
341 /* }}} */
342 
343 /* {{{ zend_implement_iterator */
zend_implement_iterator(zend_class_entry * interface,zend_class_entry * class_type)344 static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry *class_type)
345 {
346 	if (class_type->get_iterator && class_type->get_iterator != zend_user_it_get_iterator) {
347 		if (class_type->type == ZEND_INTERNAL_CLASS) {
348 			/* inheritance ensures the class has the necessary userland methods */
349 			return SUCCESS;
350 		} else {
351 			/* c-level get_iterator cannot be changed */
352 			if (class_type->get_iterator == zend_user_it_get_new_iterator) {
353 				zend_error_noreturn(E_ERROR, "Class %s cannot implement both %s and %s at the same time",
354 							ZSTR_VAL(class_type->name),
355 							ZSTR_VAL(interface->name),
356 							ZSTR_VAL(zend_ce_aggregate->name));
357 			}
358 			return FAILURE;
359 		}
360 	}
361 	class_type->get_iterator = zend_user_it_get_iterator;
362 	class_type->iterator_funcs.zf_valid = NULL;
363 	class_type->iterator_funcs.zf_current = NULL;
364 	class_type->iterator_funcs.zf_key = NULL;
365 	class_type->iterator_funcs.zf_next = NULL;
366 	class_type->iterator_funcs.zf_rewind = NULL;
367 	if (!class_type->iterator_funcs.funcs) {
368 		class_type->iterator_funcs.funcs = &zend_interface_iterator_funcs_iterator;
369 	}
370 	return SUCCESS;
371 }
372 /* }}} */
373 
374 /* {{{ zend_implement_arrayaccess */
zend_implement_arrayaccess(zend_class_entry * interface,zend_class_entry * class_type)375 static int zend_implement_arrayaccess(zend_class_entry *interface, zend_class_entry *class_type)
376 {
377 	return SUCCESS;
378 }
379 /* }}}*/
380 
381 /* {{{ zend_user_serialize */
zend_user_serialize(zval * object,unsigned char ** buffer,size_t * buf_len,zend_serialize_data * data)382 ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data)
383 {
384 	zend_class_entry * ce = Z_OBJCE_P(object);
385 	zval retval;
386 	int result;
387 
388 	zend_call_method_with_0_params(object, ce, &ce->serialize_func, "serialize", &retval);
389 
390 
391 	if (Z_TYPE(retval) == IS_UNDEF || EG(exception)) {
392 		result = FAILURE;
393 	} else {
394 		switch(Z_TYPE(retval)) {
395 		case IS_NULL:
396 			/* we could also make this '*buf_len = 0' but this allows to skip variables */
397 			zval_ptr_dtor(&retval);
398 			return FAILURE;
399 		case IS_STRING:
400 			*buffer = (unsigned char*)estrndup(Z_STRVAL(retval), Z_STRLEN(retval));
401 			*buf_len = Z_STRLEN(retval);
402 			result = SUCCESS;
403 			break;
404 		default: /* failure */
405 			result = FAILURE;
406 			break;
407 		}
408 		zval_ptr_dtor(&retval);
409 	}
410 
411 	if (result == FAILURE && !EG(exception)) {
412 		zend_throw_exception_ex(NULL, 0, "%s::serialize() must return a string or NULL", ZSTR_VAL(ce->name));
413 	}
414 	return result;
415 }
416 /* }}} */
417 
418 /* {{{ zend_user_unserialize */
zend_user_unserialize(zval * object,zend_class_entry * ce,const unsigned char * buf,size_t buf_len,zend_unserialize_data * data)419 ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data)
420 {
421 	zval zdata;
422 
423 	if (UNEXPECTED(object_init_ex(object, ce) != SUCCESS)) {
424 		return FAILURE;
425 	}
426 
427 	ZVAL_STRINGL(&zdata, (char*)buf, buf_len);
428 
429 	zend_call_method_with_1_params(object, ce, &ce->unserialize_func, "unserialize", NULL, &zdata);
430 
431 	zval_ptr_dtor(&zdata);
432 
433 	if (EG(exception)) {
434 		return FAILURE;
435 	} else {
436 		return SUCCESS;
437 	}
438 }
439 /* }}} */
440 
zend_class_serialize_deny(zval * object,unsigned char ** buffer,size_t * buf_len,zend_serialize_data * data)441 ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) /* {{{ */
442 {
443 	zend_class_entry *ce = Z_OBJCE_P(object);
444 	zend_throw_exception_ex(NULL, 0, "Serialization of '%s' is not allowed", ZSTR_VAL(ce->name));
445 	return FAILURE;
446 }
447 /* }}} */
448 
zend_class_unserialize_deny(zval * object,zend_class_entry * ce,const unsigned char * buf,size_t buf_len,zend_unserialize_data * data)449 ZEND_API int zend_class_unserialize_deny(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data) /* {{{ */
450 {
451 	zend_throw_exception_ex(NULL, 0, "Unserialization of '%s' is not allowed", ZSTR_VAL(ce->name));
452 	return FAILURE;
453 }
454 /* }}} */
455 
456 /* {{{ zend_implement_serializable */
zend_implement_serializable(zend_class_entry * interface,zend_class_entry * class_type)457 static int zend_implement_serializable(zend_class_entry *interface, zend_class_entry *class_type)
458 {
459 	if (class_type->parent
460 		&& (class_type->parent->serialize || class_type->parent->unserialize)
461 		&& !instanceof_function_ex(class_type->parent, zend_ce_serializable, 1)) {
462 		return FAILURE;
463 	}
464 	if (!class_type->serialize) {
465 		class_type->serialize = zend_user_serialize;
466 	}
467 	if (!class_type->unserialize) {
468 		class_type->unserialize = zend_user_unserialize;
469 	}
470 	return SUCCESS;
471 }
472 /* }}}*/
473 
474 /* {{{ zend_implement_countable */
zend_implement_countable(zend_class_entry * interface,zend_class_entry * class_type)475 static int zend_implement_countable(zend_class_entry *interface, zend_class_entry *class_type)
476 {
477 	return SUCCESS;
478 }
479 /* }}}*/
480 
481 /* {{{ function tables */
482 const zend_function_entry zend_funcs_aggregate[] = {
483 	ZEND_ABSTRACT_ME(iterator, getIterator, NULL)
484 	ZEND_FE_END
485 };
486 
487 const zend_function_entry zend_funcs_iterator[] = {
488 	ZEND_ABSTRACT_ME(iterator, current,  NULL)
489 	ZEND_ABSTRACT_ME(iterator, next,     NULL)
490 	ZEND_ABSTRACT_ME(iterator, key,      NULL)
491 	ZEND_ABSTRACT_ME(iterator, valid,    NULL)
492 	ZEND_ABSTRACT_ME(iterator, rewind,   NULL)
493 	ZEND_FE_END
494 };
495 
496 const zend_function_entry *zend_funcs_traversable    = NULL;
497 
498 ZEND_BEGIN_ARG_INFO_EX(arginfo_arrayaccess_offset, 0, 0, 1)
499 	ZEND_ARG_INFO(0, offset)
500 ZEND_END_ARG_INFO()
501 
502 ZEND_BEGIN_ARG_INFO_EX(arginfo_arrayaccess_offset_get, 0, 0, 1) /* actually this should be return by ref but atm cannot be */
503 	ZEND_ARG_INFO(0, offset)
504 ZEND_END_ARG_INFO()
505 
506 ZEND_BEGIN_ARG_INFO_EX(arginfo_arrayaccess_offset_value, 0, 0, 2)
507 	ZEND_ARG_INFO(0, offset)
508 	ZEND_ARG_INFO(0, value)
509 ZEND_END_ARG_INFO()
510 
511 const zend_function_entry zend_funcs_arrayaccess[] = {
512 	ZEND_ABSTRACT_ME(arrayaccess, offsetExists, arginfo_arrayaccess_offset)
513 	ZEND_ABSTRACT_ME(arrayaccess, offsetGet,    arginfo_arrayaccess_offset_get)
514 	ZEND_ABSTRACT_ME(arrayaccess, offsetSet,    arginfo_arrayaccess_offset_value)
515 	ZEND_ABSTRACT_ME(arrayaccess, offsetUnset,  arginfo_arrayaccess_offset)
516 	ZEND_FE_END
517 };
518 
519 ZEND_BEGIN_ARG_INFO(arginfo_serializable_serialize, 0)
520 	ZEND_ARG_INFO(0, serialized)
521 ZEND_END_ARG_INFO()
522 
523 const zend_function_entry zend_funcs_serializable[] = {
524 	ZEND_ABSTRACT_ME(serializable, serialize,   NULL)
525 	ZEND_FENTRY(unserialize, NULL, arginfo_serializable_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT|ZEND_ACC_CTOR)
526 	ZEND_FE_END
527 };
528 
529 ZEND_BEGIN_ARG_INFO(arginfo_countable_count, 0)
530 ZEND_END_ARG_INFO()
531 
532 const zend_function_entry zend_funcs_countable[] = {
533 	ZEND_ABSTRACT_ME(Countable, count, arginfo_countable_count)
534 	ZEND_FE_END
535 };
536 /* }}} */
537 
538 /* {{{ zend_register_interfaces */
zend_register_interfaces(void)539 ZEND_API void zend_register_interfaces(void)
540 {
541 	REGISTER_MAGIC_INTERFACE(traversable, Traversable);
542 
543 	REGISTER_MAGIC_INTERFACE(aggregate, IteratorAggregate);
544 	REGISTER_MAGIC_IMPLEMENT(aggregate, traversable);
545 
546 	REGISTER_MAGIC_INTERFACE(iterator, Iterator);
547 	REGISTER_MAGIC_IMPLEMENT(iterator, traversable);
548 
549 	REGISTER_MAGIC_INTERFACE(arrayaccess, ArrayAccess);
550 
551 	REGISTER_MAGIC_INTERFACE(serializable, Serializable);
552 
553 	REGISTER_MAGIC_INTERFACE(countable, Countable);
554 }
555 /* }}} */
556 
557 /*
558  * Local variables:
559  * tab-width: 4
560  * c-basic-offset: 4
561  * indent-tabs-mode: t
562  * End:
563  * vim600: sw=4 ts=4 fdm=marker
564  * vim<600: sw=4 ts=4
565  */
566