PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - Zend - zend_interfaces.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 219 230 95.2 %
Date: 2016-09-18 Functions: 21 21 100.0 %
Legend: Lines: hit not hit

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

Generated by: LCOV version 1.10

Generated at Sun, 18 Sep 2016 08:19:58 +0000 (8 days ago)

Copyright © 2005-2016 The PHP Group
All rights reserved.