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-08-24 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      559405 : 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      559405 :         if (param_count > 0) {
      44        5356 :                 ZVAL_COPY_VALUE(&params[0], arg1);
      45             :         }
      46      559405 :         if (param_count > 1) {
      47        2395 :                 ZVAL_COPY_VALUE(&params[1], arg2);
      48             :         }
      49             : 
      50      559405 :         fci.size = sizeof(fci);
      51             :         /*fci.function_table = NULL; will be read form zend_class_entry of object if needed */
      52     1118748 :         fci.object = (object && Z_TYPE_P(object) == IS_OBJECT) ? Z_OBJ_P(object) : NULL;
      53     1118810 :         ZVAL_STRINGL(&fci.function_name, function_name, function_name_len);
      54      559405 :         fci.retval = retval_ptr ? retval_ptr : &retval;
      55      559405 :         fci.param_count = param_count;
      56      559405 :         fci.params = params;
      57      559405 :         fci.no_separation = 1;
      58             : 
      59      559443 :         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      559367 :                 fcic.initialized = 1;
      68      559367 :                 if (!obj_ce) {
      69          51 :                         obj_ce = object ? Z_OBJCE_P(object) : NULL;
      70             :                 }
      71      559367 :                 if (obj_ce) {
      72      559316 :                         function_table = &obj_ce->function_table;
      73             :                 } else {
      74          51 :                         function_table = EG(function_table);
      75             :                 }
      76      571856 :                 if (!fn_proxy || !*fn_proxy) {
      77       24978 :                         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       12489 :                         if (fn_proxy) {
      82        1164 :                                 *fn_proxy = fcic.function_handler;
      83             :                         }
      84             :                 } else {
      85      546878 :                         fcic.function_handler = *fn_proxy;
      86             :                 }
      87      559367 :                 fcic.calling_scope = obj_ce;
      88      559367 :                 if (object) {
      89      559305 :                         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      559367 :                 fcic.object = object ? Z_OBJ_P(object) : NULL;
     102      559367 :                 result = zend_call_function(&fci, &fcic);
     103      559362 :                 zval_ptr_dtor(&fci.function_name);
     104             :         }
     105      559400 :         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      564756 :         if (param_count > 0 && Z_ISREF(params[0]) && !Z_ISREF_P(arg1)) {
     116           0 :                 ZVAL_COPY_VALUE(arg1, &params[0]);
     117             :         }
     118      561795 :         if (param_count > 1 && Z_ISREF(params[1]) && !Z_ISREF_P(arg2)) {
     119           0 :                 ZVAL_COPY_VALUE(arg2, &params[1]);
     120             :         }
     121      559400 :         if (!retval_ptr) {
     122      212818 :                 zval_ptr_dtor(&retval);
     123      212818 :                 return NULL;
     124             :         }
     125      346582 :         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      414122 : ZEND_API void zend_user_it_invalidate_current(zend_object_iterator *_iter)
     140             : {
     141      414122 :         zend_user_iterator *iter = (zend_user_iterator*)_iter;
     142             : 
     143      828244 :         if (!Z_ISUNDEF(iter->value)) {
     144       10090 :                 zval_ptr_dtor(&iter->value);
     145       10090 :                 ZVAL_UNDEF(&iter->value);
     146             :         }
     147      414122 : }
     148             : /* }}} */
     149             : 
     150             : /* {{{ zend_user_it_dtor */
     151         590 : static void zend_user_it_dtor(zend_object_iterator *_iter)
     152             : {
     153         590 :         zend_user_iterator *iter = (zend_user_iterator*)_iter;
     154         590 :         zval *object = &iter->it.data;
     155             : 
     156         590 :         zend_user_it_invalidate_current(_iter);
     157         590 :         zval_ptr_dtor(object);
     158         590 : }
     159             : /* }}} */
     160             : 
     161             : /* {{{ zend_user_it_valid */
     162       13910 : ZEND_API int zend_user_it_valid(zend_object_iterator *_iter)
     163             : {
     164       13910 :         if (_iter) {
     165       13910 :                 zend_user_iterator *iter = (zend_user_iterator*)_iter;
     166       13910 :                 zval *object = &iter->it.data;
     167             :                 zval more;
     168             :                 int result;
     169             : 
     170       13910 :                 zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_valid, "valid", &more);
     171       13910 :                 if (Z_TYPE(more) != IS_UNDEF) {
     172       13897 :                         result = i_zend_is_true(&more);
     173       13897 :                         zval_ptr_dtor(&more);
     174       13897 :                         return result ? SUCCESS : FAILURE;
     175             :                 }
     176             :         }
     177          13 :         return FAILURE;
     178             : }
     179             : /* }}} */
     180             : 
     181             : /* {{{ zend_user_it_get_current_data */
     182       10140 : ZEND_API zval *zend_user_it_get_current_data(zend_object_iterator *_iter)
     183             : {
     184       10140 :         zend_user_iterator *iter = (zend_user_iterator*)_iter;
     185       10140 :         zval *object = &iter->it.data;
     186             : 
     187       20280 :         if (Z_ISUNDEF(iter->value)) {
     188       10103 :                 zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_current, "current", &iter->value);
     189             :         }
     190       10140 :         return &iter->value;
     191             : }
     192             : /* }}} */
     193             : 
     194             : /* {{{ zend_user_it_get_current_key_default */
     195             : #if 0
     196             : static int zend_user_it_get_current_key_default(zend_object_iterator *_iter, char **str_key, uint *str_key_len, ulong *int_key)
     197             : {
     198             :         *int_key = _iter->index;
     199             :         return HASH_KEY_IS_LONG;
     200             : }
     201             : #endif
     202             : /* }}} */
     203             : 
     204             : /* {{{ zend_user_it_get_current_key */
     205        7735 : ZEND_API void zend_user_it_get_current_key(zend_object_iterator *_iter, zval *key)
     206             : {
     207        7735 :         zend_user_iterator *iter = (zend_user_iterator*)_iter;
     208        7735 :         zval *object = &iter->it.data;
     209             :         zval retval;
     210             : 
     211        7735 :         zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_key, "key", &retval);
     212             : 
     213        7735 :         if (Z_TYPE(retval) != IS_UNDEF) {
     214       15450 :                 ZVAL_ZVAL(key, &retval, 1, 1);
     215             :         } else {
     216          10 :                 if (!EG(exception)) {
     217           0 :                         zend_error(E_WARNING, "Nothing returned from %s::key()", ZSTR_VAL(iter->ce->name));
     218             :                 }
     219             : 
     220          10 :                 ZVAL_LONG(key, 0);
     221             :         }
     222        7735 : }
     223             : /* }}} */
     224             : 
     225             : /* {{{ zend_user_it_move_forward */
     226       10190 : ZEND_API void zend_user_it_move_forward(zend_object_iterator *_iter)
     227             : {
     228       10190 :         zend_user_iterator *iter = (zend_user_iterator*)_iter;
     229       10190 :         zval *object = &iter->it.data;
     230             : 
     231       10190 :         zend_user_it_invalidate_current(_iter);
     232       10190 :         zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_next, "next", NULL);
     233       10190 : }
     234             : /* }}} */
     235             : 
     236             : /* {{{ zend_user_it_rewind */
     237         674 : ZEND_API void zend_user_it_rewind(zend_object_iterator *_iter)
     238             : {
     239         674 :         zend_user_iterator *iter = (zend_user_iterator*)_iter;
     240         674 :         zval *object = &iter->it.data;
     241             : 
     242         674 :         zend_user_it_invalidate_current(_iter);
     243         674 :         zend_call_method_with_0_params(object, iter->ce, &iter->ce->iterator_funcs.zf_rewind, "rewind", NULL);
     244         674 : }
     245             : /* }}} */
     246             : 
     247             : zend_object_iterator_funcs zend_interface_iterator_funcs_iterator = {
     248             :         zend_user_it_dtor,
     249             :         zend_user_it_valid,
     250             :         zend_user_it_get_current_data,
     251             :         zend_user_it_get_current_key,
     252             :         zend_user_it_move_forward,
     253             :         zend_user_it_rewind,
     254             :         zend_user_it_invalidate_current
     255             : };
     256             : 
     257             : /* {{{ zend_user_it_get_iterator */
     258         592 : static zend_object_iterator *zend_user_it_get_iterator(zend_class_entry *ce, zval *object, int by_ref)
     259             : {
     260             :         zend_user_iterator *iterator;
     261             : 
     262         592 :         if (by_ref) {
     263           2 :                 zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
     264           2 :                 return NULL;
     265             :         }
     266             : 
     267         590 :         iterator = emalloc(sizeof(zend_user_iterator));
     268             : 
     269         590 :         zend_iterator_init((zend_object_iterator*)iterator);
     270             : 
     271         590 :         ZVAL_COPY(&iterator->it.data, object);
     272         590 :         iterator->it.funcs = ce->iterator_funcs.funcs;
     273         590 :         iterator->ce = Z_OBJCE_P(object);
     274         590 :         ZVAL_UNDEF(&iterator->value);
     275         590 :         return (zend_object_iterator*)iterator;
     276             : }
     277             : /* }}} */
     278             : 
     279             : /* {{{ zend_user_it_get_new_iterator */
     280          86 : ZEND_API zend_object_iterator *zend_user_it_get_new_iterator(zend_class_entry *ce, zval *object, int by_ref)
     281             : {
     282             :         zval iterator;
     283             :         zend_object_iterator *new_iterator;
     284             :         zend_class_entry *ce_it;
     285             : 
     286          86 :         zend_user_it_new_iterator(ce, object, &iterator);
     287          86 :         ce_it = (Z_TYPE(iterator) == IS_OBJECT) ? Z_OBJCE(iterator) : NULL;
     288             : 
     289          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))) {
     290           8 :                 if (!EG(exception)) {
     291           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));
     292             :                 }
     293           8 :                 zval_ptr_dtor(&iterator);
     294           8 :                 return NULL;
     295             :         }
     296             : 
     297          78 :         new_iterator = ce_it->get_iterator(ce_it, &iterator, by_ref);
     298          78 :         zval_ptr_dtor(&iterator);
     299          78 :         return new_iterator;
     300             : }
     301             : /* }}} */
     302             : 
     303             : /* {{{ zend_implement_traversable */
     304     1222558 : static int zend_implement_traversable(zend_class_entry *interface, zend_class_entry *class_type)
     305             : {
     306             :         /* check that class_type is traversable at c-level or implements at least one of 'aggregate' and 'Iterator' */
     307             :         uint32_t i;
     308             : 
     309     1222558 :         if (class_type->get_iterator || (class_type->parent && class_type->parent->get_iterator)) {
     310     1199052 :                 return SUCCESS;
     311             :         }
     312       70517 :         for (i = 0; i < class_type->num_interfaces; i++) {
     313       70516 :                 if (class_type->interfaces[i] == zend_ce_aggregate || class_type->interfaces[i] == zend_ce_iterator) {
     314       23505 :                         return SUCCESS;
     315             :                 }
     316             :         }
     317           4 :         zend_error_noreturn(E_CORE_ERROR, "Class %s must implement interface %s as part of either %s or %s",
     318           1 :                 ZSTR_VAL(class_type->name),
     319           1 :                 ZSTR_VAL(zend_ce_traversable->name),
     320           1 :                 ZSTR_VAL(zend_ce_iterator->name),
     321           1 :                 ZSTR_VAL(zend_ce_aggregate->name));
     322             :         return FAILURE;
     323             : }
     324             : /* }}} */
     325             : 
     326             : /* {{{ zend_implement_aggregate */
     327       23584 : static int zend_implement_aggregate(zend_class_entry *interface, zend_class_entry *class_type)
     328             : {
     329             :         uint32_t i;
     330       23584 :         int t = -1;
     331             : 
     332       23584 :         if (class_type->get_iterator) {
     333           7 :                 if (class_type->type == ZEND_INTERNAL_CLASS) {
     334             :                         /* inheritance ensures the class has necessary userland methods */
     335           0 :                         return SUCCESS;
     336           7 :                 } else if (class_type->get_iterator != zend_user_it_get_new_iterator) {
     337             :                         /* c-level get_iterator cannot be changed (exception being only Traversable is implmented) */
     338           7 :                         if (class_type->num_interfaces) {
     339          19 :                                 for (i = 0; i < class_type->num_interfaces; i++) {
     340          13 :                                         if (class_type->interfaces[i] == zend_ce_iterator) {
     341           3 :                                                 zend_error_noreturn(E_ERROR, "Class %s cannot implement both %s and %s at the same time",
     342           1 :                                                                         ZSTR_VAL(class_type->name),
     343           1 :                                                                         ZSTR_VAL(interface->name),
     344           1 :                                                                         ZSTR_VAL(zend_ce_iterator->name));
     345             :                                                 return FAILURE;
     346             :                                         }
     347          12 :                                         if (class_type->interfaces[i] == zend_ce_traversable) {
     348           6 :                                                 t = i;
     349             :                                         }
     350             :                                 }
     351             :                         }
     352           6 :                         if (t == -1) {
     353           0 :                                 return FAILURE;
     354             :                         }
     355             :                 }
     356             :         }
     357       23583 :         class_type->iterator_funcs.zf_new_iterator = NULL;
     358       23583 :         class_type->get_iterator = zend_user_it_get_new_iterator;
     359       23583 :         return SUCCESS;
     360             : }
     361             : /* }}} */
     362             : 
     363             : /* {{{ zend_implement_iterator */
     364      963877 : static int zend_implement_iterator(zend_class_entry *interface, zend_class_entry *class_type)
     365             : {
     366      963877 :         if (class_type->get_iterator && class_type->get_iterator != zend_user_it_get_iterator) {
     367       47009 :                 if (class_type->type == ZEND_INTERNAL_CLASS) {
     368             :                         /* inheritance ensures the class has the necessary userland methods */
     369       47008 :                         return SUCCESS;
     370             :                 } else {
     371             :                         /* c-level get_iterator cannot be changed */
     372           1 :                         if (class_type->get_iterator == zend_user_it_get_new_iterator) {
     373           3 :                                 zend_error_noreturn(E_ERROR, "Class %s cannot implement both %s and %s at the same time",
     374           1 :                                                         ZSTR_VAL(class_type->name),
     375           1 :                                                         ZSTR_VAL(interface->name),
     376           1 :                                                         ZSTR_VAL(zend_ce_aggregate->name));
     377             :                         }
     378           0 :                         return FAILURE;
     379             :                 }
     380             :         }
     381      916868 :         class_type->get_iterator = zend_user_it_get_iterator;
     382      916868 :         class_type->iterator_funcs.zf_valid = NULL;
     383      916868 :         class_type->iterator_funcs.zf_current = NULL;
     384      916868 :         class_type->iterator_funcs.zf_key = NULL;
     385      916868 :         class_type->iterator_funcs.zf_next = NULL;
     386      916868 :         class_type->iterator_funcs.zf_rewind = NULL;
     387      916868 :         if (!class_type->iterator_funcs.funcs) {
     388      916868 :                 class_type->iterator_funcs.funcs = &zend_interface_iterator_funcs_iterator;
     389             :         }
     390      916868 :         return SUCCESS;
     391             : }
     392             : /* }}} */
     393             : 
     394             : /* {{{ zend_implement_arrayaccess */
     395      282195 : static int zend_implement_arrayaccess(zend_class_entry *interface, zend_class_entry *class_type)
     396             : {
     397             : #if 0
     398             :         /* get ht from ce */
     399             :         if (ht->read_dimension != zend_std_read_dimension
     400             :         ||  ht->write_dimension != zend_std_write_dimension
     401             :         ||  ht->has_dimension != zend_std_has_dimension
     402             :         ||  ht->unset_dimension != zend_std_unset_dimension) {
     403             :                 return FAILURE;
     404             :         }
     405             : #endif
     406      282195 :         return SUCCESS;
     407             : }
     408             : /* }}}*/
     409             : 
     410             : /* {{{ zend_user_serialize */
     411          58 : ZEND_API int zend_user_serialize(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data)
     412             : {
     413          58 :         zend_class_entry * ce = Z_OBJCE_P(object);
     414             :         zval retval;
     415             :         int result;
     416             : 
     417          58 :         zend_call_method_with_0_params(object, ce, &ce->serialize_func, "serialize", &retval);
     418             : 
     419             : 
     420          59 :         if (Z_TYPE(retval) == IS_UNDEF || EG(exception)) {
     421           1 :                 result = FAILURE;
     422             :         } else {
     423          57 :                 switch(Z_TYPE(retval)) {
     424             :                 case IS_NULL:
     425             :                         /* we could also make this '*buf_len = 0' but this allows to skip variables */
     426           2 :                         zval_ptr_dtor(&retval);
     427           2 :                         return FAILURE;
     428             :                 case IS_STRING:
     429          52 :                         *buffer = (unsigned char*)estrndup(Z_STRVAL(retval), Z_STRLEN(retval));
     430          52 :                         *buf_len = Z_STRLEN(retval);
     431          52 :                         result = SUCCESS;
     432          52 :                         break;
     433             :                 default: /* failure */
     434           3 :                         result = FAILURE;
     435             :                         break;
     436             :                 }
     437          55 :                 zval_ptr_dtor(&retval);
     438             :         }
     439             : 
     440          56 :         if (result == FAILURE && !EG(exception)) {
     441           3 :                 zend_throw_exception_ex(NULL, 0, "%s::serialize() must return a string or NULL", ZSTR_VAL(ce->name));
     442             :         }
     443          56 :         return result;
     444             : }
     445             : /* }}} */
     446             : 
     447             : /* {{{ zend_user_unserialize */
     448          86 : ZEND_API int zend_user_unserialize(zval *object, zend_class_entry *ce, const unsigned char *buf, size_t buf_len, zend_unserialize_data *data)
     449             : {
     450             :         zval zdata;
     451             : 
     452          86 :         if (UNEXPECTED(object_init_ex(object, ce) != SUCCESS)) {
     453           0 :                 return FAILURE;
     454             :         }
     455             : 
     456         172 :         ZVAL_STRINGL(&zdata, (char*)buf, buf_len);
     457             : 
     458          86 :         zend_call_method_with_1_params(object, ce, &ce->unserialize_func, "unserialize", NULL, &zdata);
     459             : 
     460          86 :         zval_ptr_dtor(&zdata);
     461             : 
     462          86 :         if (EG(exception)) {
     463           2 :                 return FAILURE;
     464             :         } else {
     465          84 :                 return SUCCESS;
     466             :         }
     467             : }
     468             : /* }}} */
     469             : 
     470           2 : ZEND_API int zend_class_serialize_deny(zval *object, unsigned char **buffer, size_t *buf_len, zend_serialize_data *data) /* {{{ */
     471             : {
     472           2 :         zend_class_entry *ce = Z_OBJCE_P(object);
     473           2 :         zend_throw_exception_ex(NULL, 0, "Serialization of '%s' is not allowed", ZSTR_VAL(ce->name));
     474           2 :         return FAILURE;
     475             : }
     476             : /* }}} */
     477             : 
     478           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) /* {{{ */
     479             : {
     480           1 :         zend_throw_exception_ex(NULL, 0, "Unserialization of '%s' is not allowed", ZSTR_VAL(ce->name));
     481           1 :         return FAILURE;
     482             : }
     483             : /* }}} */
     484             : 
     485             : /* {{{ zend_implement_serializable */
     486      164664 : static int zend_implement_serializable(zend_class_entry *interface, zend_class_entry *class_type)
     487             : {
     488      305902 :         if (class_type->parent
     489      235283 :                 && (class_type->parent->serialize || class_type->parent->unserialize)
     490       70619 :                 && !instanceof_function_ex(class_type->parent, zend_ce_serializable, 1)) {
     491           0 :                 return FAILURE;
     492             :         }
     493      164664 :         if (!class_type->serialize) {
     494      164664 :                 class_type->serialize = zend_user_serialize;
     495             :         }
     496      164664 :         if (!class_type->unserialize) {
     497      164664 :                 class_type->unserialize = zend_user_unserialize;
     498             :         }
     499      164664 :         return SUCCESS;
     500             : }
     501             : /* }}}*/
     502             : 
     503             : /* {{{ function tables */
     504             : const zend_function_entry zend_funcs_aggregate[] = {
     505             :         ZEND_ABSTRACT_ME(iterator, getIterator, NULL)
     506             :         ZEND_FE_END
     507             : };
     508             : 
     509             : const zend_function_entry zend_funcs_iterator[] = {
     510             :         ZEND_ABSTRACT_ME(iterator, current,  NULL)
     511             :         ZEND_ABSTRACT_ME(iterator, next,     NULL)
     512             :         ZEND_ABSTRACT_ME(iterator, key,      NULL)
     513             :         ZEND_ABSTRACT_ME(iterator, valid,    NULL)
     514             :         ZEND_ABSTRACT_ME(iterator, rewind,   NULL)
     515             :         ZEND_FE_END
     516             : };
     517             : 
     518             : const zend_function_entry *zend_funcs_traversable    = NULL;
     519             : 
     520             : ZEND_BEGIN_ARG_INFO_EX(arginfo_arrayaccess_offset, 0, 0, 1)
     521             :         ZEND_ARG_INFO(0, offset)
     522             : ZEND_END_ARG_INFO()
     523             : 
     524             : ZEND_BEGIN_ARG_INFO_EX(arginfo_arrayaccess_offset_get, 0, 0, 1) /* actually this should be return by ref but atm cannot be */
     525             :         ZEND_ARG_INFO(0, offset)
     526             : ZEND_END_ARG_INFO()
     527             : 
     528             : ZEND_BEGIN_ARG_INFO_EX(arginfo_arrayaccess_offset_value, 0, 0, 2)
     529             :         ZEND_ARG_INFO(0, offset)
     530             :         ZEND_ARG_INFO(0, value)
     531             : ZEND_END_ARG_INFO()
     532             : 
     533             : const zend_function_entry zend_funcs_arrayaccess[] = {
     534             :         ZEND_ABSTRACT_ME(arrayaccess, offsetExists, arginfo_arrayaccess_offset)
     535             :         ZEND_ABSTRACT_ME(arrayaccess, offsetGet,    arginfo_arrayaccess_offset_get)
     536             :         ZEND_ABSTRACT_ME(arrayaccess, offsetSet,    arginfo_arrayaccess_offset_value)
     537             :         ZEND_ABSTRACT_ME(arrayaccess, offsetUnset,  arginfo_arrayaccess_offset)
     538             :         ZEND_FE_END
     539             : };
     540             : 
     541             : ZEND_BEGIN_ARG_INFO(arginfo_serializable_serialize, 0)
     542             :         ZEND_ARG_INFO(0, serialized)
     543             : ZEND_END_ARG_INFO()
     544             : 
     545             : const zend_function_entry zend_funcs_serializable[] = {
     546             :         ZEND_ABSTRACT_ME(serializable, serialize,   NULL)
     547             :         ZEND_FENTRY(unserialize, NULL, arginfo_serializable_serialize, ZEND_ACC_PUBLIC|ZEND_ACC_ABSTRACT|ZEND_ACC_CTOR)
     548             :         ZEND_FE_END
     549             : };
     550             : /* }}} */
     551             : 
     552             : /* {{{ zend_register_interfaces */
     553       23504 : ZEND_API void zend_register_interfaces(void)
     554             : {
     555       23504 :         REGISTER_MAGIC_INTERFACE(traversable, Traversable);
     556             : 
     557       23504 :         REGISTER_MAGIC_INTERFACE(aggregate, IteratorAggregate);
     558       23504 :         REGISTER_MAGIC_IMPLEMENT(aggregate, traversable);
     559             : 
     560       23504 :         REGISTER_MAGIC_INTERFACE(iterator, Iterator);
     561       23504 :         REGISTER_MAGIC_IMPLEMENT(iterator, traversable);
     562             : 
     563       23504 :         REGISTER_MAGIC_INTERFACE(arrayaccess, ArrayAccess);
     564             : 
     565       23504 :         REGISTER_MAGIC_INTERFACE(serializable, Serializable);
     566       23504 : }
     567             : /* }}} */
     568             : 
     569             : /*
     570             :  * Local variables:
     571             :  * tab-width: 4
     572             :  * c-basic-offset: 4
     573             :  * indent-tabs-mode: t
     574             :  * End:
     575             :  */

Generated by: LCOV version 1.10

Generated at Wed, 24 Aug 2016 12:20:13 +0000 (3 days ago)

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