Back to index

php5  5.3.10
Classes | Defines | Typedefs | Functions | Variables
spl_array.c File Reference
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "ext/standard/php_var.h"
#include "ext/standard/php_smart_str.h"
#include "zend_interfaces.h"
#include "zend_exceptions.h"
#include "php_spl.h"
#include "spl_functions.h"
#include "spl_engine.h"
#include "spl_iterators.h"
#include "spl_array.h"
#include "spl_exceptions.h"

Go to the source code of this file.

Classes

struct  _spl_array_object
struct  spl_array_it

Defines

#define SPL_ARRAY_STD_PROP_LIST   0x00000001
#define SPL_ARRAY_ARRAY_AS_PROPS   0x00000002
#define SPL_ARRAY_CHILD_ARRAYS_ONLY   0x00000004
#define SPL_ARRAY_OVERLOADED_REWIND   0x00010000
#define SPL_ARRAY_OVERLOADED_VALID   0x00020000
#define SPL_ARRAY_OVERLOADED_KEY   0x00040000
#define SPL_ARRAY_OVERLOADED_CURRENT   0x00080000
#define SPL_ARRAY_OVERLOADED_NEXT   0x00100000
#define SPL_ARRAY_IS_REF   0x01000000
#define SPL_ARRAY_IS_SELF   0x02000000
#define SPL_ARRAY_USE_OTHER   0x04000000
#define SPL_ARRAY_INT_MASK   0xFFFF0000
#define SPL_ARRAY_CLONE_MASK   0x0300FFFF
#define SPL_ARRAY_METHOD(cname, fname, use_arg)

Typedefs

typedef struct _spl_array_object spl_array_object

Functions

static HashTablespl_array_get_hash_table (spl_array_object *intern, int check_std_props TSRMLS_DC)
static void spl_array_rewind (spl_array_object *intern TSRMLS_DC)
static void spl_array_update_pos (spl_array_object *intern)
static void spl_array_set_pos (spl_array_object *intern, HashPosition pos)
SPL_API int spl_hash_verify_pos_ex (spl_array_object *intern, HashTable *ht TSRMLS_DC)
SPL_API int spl_hash_verify_pos (spl_array_object *intern TSRMLS_DC)
static void spl_array_object_free_storage (void *object TSRMLS_DC)
zend_object_iterator * spl_array_get_iterator (zend_class_entry *ce, zval *object, int by_ref TSRMLS_DC)
int spl_array_serialize (zval *object, unsigned char **buffer, zend_uint *buf_len, zend_serialize_data *data TSRMLS_DC)
int spl_array_unserialize (zval **object, zend_class_entry *ce, const unsigned char *buf, zend_uint buf_len, zend_unserialize_data *data TSRMLS_DC)
static zend_object_value spl_array_object_new_ex (zend_class_entry *class_type, spl_array_object **obj, zval *orig, int clone_orig TSRMLS_DC)
static zend_object_value spl_array_object_new (zend_class_entry *class_type TSRMLS_DC)
static zend_object_value spl_array_object_clone (zval *zobject TSRMLS_DC)
static zval ** spl_array_get_dimension_ptr_ptr (int check_inherited, zval *object, zval *offset, int type TSRMLS_DC)
static zval * spl_array_read_dimension_ex (int check_inherited, zval *object, zval *offset, int type TSRMLS_DC)
static zval * spl_array_read_dimension (zval *object, zval *offset, int type TSRMLS_DC)
static void spl_array_write_dimension_ex (int check_inherited, zval *object, zval *offset, zval *value TSRMLS_DC)
static void spl_array_write_dimension (zval *object, zval *offset, zval *value TSRMLS_DC)
static void spl_array_unset_dimension_ex (int check_inherited, zval *object, zval *offset TSRMLS_DC)
static void spl_array_unset_dimension (zval *object, zval *offset TSRMLS_DC)
static int spl_array_has_dimension_ex (int check_inherited, zval *object, zval *offset, int check_empty TSRMLS_DC)
static int spl_array_has_dimension (zval *object, zval *offset, int check_empty TSRMLS_DC)
 SPL_METHOD (Array, offsetExists)
 SPL_METHOD (Array, offsetGet)
 SPL_METHOD (Array, offsetSet)
void spl_array_iterator_append (zval *object, zval *append_value TSRMLS_DC)
 SPL_METHOD (Array, append)
 SPL_METHOD (Array, offsetUnset)
 SPL_METHOD (Array, getArrayCopy)
static HashTablespl_array_get_properties (zval *object TSRMLS_DC)
static HashTablespl_array_get_debug_info (zval *obj, int *is_temp TSRMLS_DC)
static zval * spl_array_read_property (zval *object, zval *member, int type TSRMLS_DC)
static void spl_array_write_property (zval *object, zval *member, zval *value TSRMLS_DC)
static zval ** spl_array_get_property_ptr_ptr (zval *object, zval *member TSRMLS_DC)
static int spl_array_has_property (zval *object, zval *member, int has_set_exists TSRMLS_DC)
static void spl_array_unset_property (zval *object, zval *member TSRMLS_DC)
static int spl_array_skip_protected (spl_array_object *intern, HashTable *aht TSRMLS_DC)
static int spl_array_next_no_verify (spl_array_object *intern, HashTable *aht TSRMLS_DC)
static int spl_array_next_ex (spl_array_object *intern, HashTable *aht TSRMLS_DC)
static int spl_array_next (spl_array_object *intern TSRMLS_DC)
static void spl_array_it_dtor (zend_object_iterator *iter TSRMLS_DC)
static int spl_array_it_valid (zend_object_iterator *iter TSRMLS_DC)
static void spl_array_it_get_current_data (zend_object_iterator *iter, zval ***data TSRMLS_DC)
static int spl_array_it_get_current_key (zend_object_iterator *iter, char **str_key, uint *str_key_len, ulong *int_key TSRMLS_DC)
static void spl_array_it_move_forward (zend_object_iterator *iter TSRMLS_DC)
static void spl_array_rewind_ex (spl_array_object *intern, HashTable *aht TSRMLS_DC)
static void spl_array_it_rewind (zend_object_iterator *iter TSRMLS_DC)
static void spl_array_set_array (zval *object, spl_array_object *intern, zval **array, long ar_flags, int just_array TSRMLS_DC)
 SPL_METHOD (Array, __construct)
 SPL_METHOD (Array, setIteratorClass)
 SPL_METHOD (Array, getIteratorClass)
 SPL_METHOD (Array, getFlags)
 SPL_METHOD (Array, setFlags)
 SPL_METHOD (Array, exchangeArray)
 SPL_METHOD (Array, getIterator)
 SPL_METHOD (Array, rewind)
 SPL_METHOD (Array, seek)
static int spl_array_object_count_elements_helper (spl_array_object *intern, long *count TSRMLS_DC)
int spl_array_object_count_elements (zval *object, long *count TSRMLS_DC)
 SPL_METHOD (Array, count)
static void spl_array_method (INTERNAL_FUNCTION_PARAMETERS, char *fname, int fname_len, int use_arg)
 SPL_ARRAY_METHOD (SPL_ARRAY_METHOD(Array, asort, 0)
 SPL_METHOD (Array, key)
void spl_array_iterator_key (zval *object, zval *return_value TSRMLS_DC)
 SPL_METHOD (Array, next)
 SPL_METHOD (Array, valid)
 SPL_METHOD (Array, hasChildren)
 SPL_METHOD (Array, getChildren)
smart_str spl_array_serialize_helper (spl_array_object *intern, php_serialize_data_t *var_hash_p TSRMLS_DC)
 SPL_METHOD (Array, serialize)
void spl_array_unserialize_helper (spl_array_object *intern, const unsigned char *buf, int buf_len, php_unserialize_data_t *var_hash_p TSRMLS_DC)
 SPL_METHOD (Array, unserialize)
 ZEND_END_ARG_INFO ()
 PHP_MINIT_FUNCTION (spl_array)

Variables

zend_object_handlers spl_handler_ArrayObject
PHPAPI zend_class_entry * spl_ce_ArrayObject
zend_object_handlers spl_handler_ArrayIterator
PHPAPI zend_class_entry * spl_ce_ArrayIterator
PHPAPI zend_class_entry * spl_ce_RecursiveArrayIterator
zend_object_iterator_funcs spl_array_it_funcs
static const zend_function_entry spl_funcs_ArrayObject []
static const zend_function_entry spl_funcs_ArrayIterator []
static const zend_function_entry spl_funcs_RecursiveArrayIterator []

Class Documentation

struct _spl_array_object

Definition at line 61 of file spl_array.c.

Collaboration diagram for _spl_array_object:
Class Members
int ar_flags
zval * array
zend_class_entry * ce_get_iterator
HashTable * debug_info
zend_function * fptr_count
zend_function * fptr_offset_del
zend_function * fptr_offset_get
zend_function * fptr_offset_has
zend_function * fptr_offset_set
zend_function * fptr_serialize
zend_function * fptr_unserialize
int is_self
unsigned char nApplyCount
HashPosition pos
ulong pos_h
zval * retval
php_serialize_data_t * serialize_data
zend_object std
php_unserialize_data_t * unserialize_data
struct spl_array_it

Definition at line 894 of file spl_array.c.

Collaboration diagram for spl_array_it:
Class Members
zend_user_iterator intern
spl_array_object * object

Define Documentation

#define SPL_ARRAY_ARRAY_AS_PROPS   0x00000002

Definition at line 48 of file spl_array.c.

#define SPL_ARRAY_CHILD_ARRAYS_ONLY   0x00000004

Definition at line 49 of file spl_array.c.

#define SPL_ARRAY_CLONE_MASK   0x0300FFFF

Definition at line 59 of file spl_array.c.

#define SPL_ARRAY_INT_MASK   0xFFFF0000

Definition at line 58 of file spl_array.c.

#define SPL_ARRAY_IS_REF   0x01000000

Definition at line 55 of file spl_array.c.

#define SPL_ARRAY_IS_SELF   0x02000000

Definition at line 56 of file spl_array.c.

#define SPL_ARRAY_METHOD (   cname,
  fname,
  use_arg 
)
Value:
SPL_METHOD(cname, fname) \
{ \
       spl_array_method(INTERNAL_FUNCTION_PARAM_PASSTHRU, #fname, sizeof(#fname)-1, use_arg); \
}

Definition at line 1401 of file spl_array.c.

#define SPL_ARRAY_OVERLOADED_CURRENT   0x00080000

Definition at line 53 of file spl_array.c.

#define SPL_ARRAY_OVERLOADED_KEY   0x00040000

Definition at line 52 of file spl_array.c.

#define SPL_ARRAY_OVERLOADED_NEXT   0x00100000

Definition at line 54 of file spl_array.c.

#define SPL_ARRAY_OVERLOADED_REWIND   0x00010000

Definition at line 50 of file spl_array.c.

#define SPL_ARRAY_OVERLOADED_VALID   0x00020000

Definition at line 51 of file spl_array.c.

#define SPL_ARRAY_STD_PROP_LIST   0x00000001

Definition at line 47 of file spl_array.c.

#define SPL_ARRAY_USE_OTHER   0x04000000

Definition at line 57 of file spl_array.c.


Typedef Documentation


Function Documentation

PHP_MINIT_FUNCTION ( spl_array  )

Definition at line 1981 of file spl_array.c.

{
       REGISTER_SPL_STD_CLASS_EX(ArrayObject, spl_array_object_new, spl_funcs_ArrayObject);
       REGISTER_SPL_IMPLEMENTS(ArrayObject, Aggregate);
       REGISTER_SPL_IMPLEMENTS(ArrayObject, ArrayAccess);
       REGISTER_SPL_IMPLEMENTS(ArrayObject, Serializable);
       spl_ce_ArrayObject->serialize   = spl_array_serialize;
       spl_ce_ArrayObject->unserialize = spl_array_unserialize;
       memcpy(&spl_handler_ArrayObject, zend_get_std_object_handlers(), sizeof(zend_object_handlers));

       spl_handler_ArrayObject.clone_obj = spl_array_object_clone;
       spl_handler_ArrayObject.read_dimension = spl_array_read_dimension;
       spl_handler_ArrayObject.write_dimension = spl_array_write_dimension;
       spl_handler_ArrayObject.unset_dimension = spl_array_unset_dimension;
       spl_handler_ArrayObject.has_dimension = spl_array_has_dimension;
       spl_handler_ArrayObject.count_elements = spl_array_object_count_elements;

       spl_handler_ArrayObject.get_properties = spl_array_get_properties;
       spl_handler_ArrayObject.get_debug_info = spl_array_get_debug_info;
       spl_handler_ArrayObject.read_property = spl_array_read_property;
       spl_handler_ArrayObject.write_property = spl_array_write_property;
       spl_handler_ArrayObject.get_property_ptr_ptr = spl_array_get_property_ptr_ptr;
       spl_handler_ArrayObject.has_property = spl_array_has_property;
       spl_handler_ArrayObject.unset_property = spl_array_unset_property;

       REGISTER_SPL_STD_CLASS_EX(ArrayIterator, spl_array_object_new, spl_funcs_ArrayIterator);
       REGISTER_SPL_IMPLEMENTS(ArrayIterator, Iterator);
       REGISTER_SPL_IMPLEMENTS(ArrayIterator, ArrayAccess);
       REGISTER_SPL_IMPLEMENTS(ArrayIterator, SeekableIterator);
       REGISTER_SPL_IMPLEMENTS(ArrayIterator, Serializable);
       spl_ce_ArrayIterator->serialize   = spl_array_serialize;
       spl_ce_ArrayIterator->unserialize = spl_array_unserialize;
       memcpy(&spl_handler_ArrayIterator, &spl_handler_ArrayObject, sizeof(zend_object_handlers));
       spl_ce_ArrayIterator->get_iterator = spl_array_get_iterator;
       
       REGISTER_SPL_SUB_CLASS_EX(RecursiveArrayIterator, ArrayIterator, spl_array_object_new, spl_funcs_RecursiveArrayIterator);
       REGISTER_SPL_IMPLEMENTS(RecursiveArrayIterator, RecursiveIterator);
       spl_ce_RecursiveArrayIterator->get_iterator = spl_array_get_iterator;

       REGISTER_SPL_IMPLEMENTS(ArrayObject, Countable);
       REGISTER_SPL_IMPLEMENTS(ArrayIterator, Countable);

       REGISTER_SPL_CLASS_CONST_LONG(ArrayObject,   "STD_PROP_LIST",    SPL_ARRAY_STD_PROP_LIST);
       REGISTER_SPL_CLASS_CONST_LONG(ArrayObject,   "ARRAY_AS_PROPS",   SPL_ARRAY_ARRAY_AS_PROPS);

       REGISTER_SPL_CLASS_CONST_LONG(ArrayIterator, "STD_PROP_LIST",    SPL_ARRAY_STD_PROP_LIST);
       REGISTER_SPL_CLASS_CONST_LONG(ArrayIterator, "ARRAY_AS_PROPS",   SPL_ARRAY_ARRAY_AS_PROPS);

       REGISTER_SPL_CLASS_CONST_LONG(RecursiveArrayIterator, "CHILD_ARRAYS_ONLY", SPL_ARRAY_CHILD_ARRAYS_ONLY);

       return SUCCESS;
}

Here is the call graph for this function:

static HashTable* spl_array_get_debug_info ( zval *  obj,
int *is_temp  TSRMLS_DC 
) [static]

Definition at line 744 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(obj TSRMLS_CC);
       zval *tmp, *storage;
       int name_len;
       char *zname;
       zend_class_entry *base;

       *is_temp = 0;

       if (HASH_OF(intern->array) == intern->std.properties) {
              return intern->std.properties;
       } else {
              if (intern->debug_info == NULL) {
                     ALLOC_HASHTABLE(intern->debug_info);
                     ZEND_INIT_SYMTABLE_EX(intern->debug_info, zend_hash_num_elements(intern->std.properties) + 1, 0);
              }

              if (intern->debug_info->nApplyCount == 0) {
                     zend_hash_clean(intern->debug_info);
                     zend_hash_copy(intern->debug_info, intern->std.properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));

                     storage = intern->array;
                     zval_add_ref(&storage);

                     base = (Z_OBJ_HT_P(obj) == &spl_handler_ArrayIterator) ? spl_ce_ArrayIterator : spl_ce_ArrayObject;
                     zname = spl_gen_private_prop_name(base, "storage", sizeof("storage")-1, &name_len TSRMLS_CC);
                     zend_symtable_update(intern->debug_info, zname, name_len+1, &storage, sizeof(zval *), NULL);
                     efree(zname);
              }

              return intern->debug_info;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static zval** spl_array_get_dimension_ptr_ptr ( int  check_inherited,
zval *  object,
zval *  offset,
int type  TSRMLS_DC 
) [static]

Definition at line 308 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       zval **retval;
       long index;
       HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);

/*  We cannot get the pointer pointer so we don't allow it here for now
       if (check_inherited && intern->fptr_offset_get) {
              return zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_get, "offsetGet", NULL, offset);
       }*/

       if (!offset) {
              return &EG(uninitialized_zval_ptr);
       }
       
       if ((type == BP_VAR_W || type == BP_VAR_RW) && (ht->nApplyCount > 0)) {
              zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
              return &EG(uninitialized_zval_ptr);;
       }

       switch(Z_TYPE_P(offset)) {
       case IS_STRING:
              if (zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &retval) == FAILURE) {
                     if (type == BP_VAR_W || type == BP_VAR_RW) {
                            zval *value;
                            ALLOC_INIT_ZVAL(value);
                            zend_symtable_update(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void**)&value, sizeof(void*), NULL);
                            zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &retval);
                            return retval;
                     } else {
                            zend_error(E_NOTICE, "Undefined index:  %s", Z_STRVAL_P(offset));
                            return &EG(uninitialized_zval_ptr);
                     }
              } else {
                     return retval;
              }
       case IS_DOUBLE:
       case IS_RESOURCE:
       case IS_BOOL: 
       case IS_LONG: 
              if (offset->type == IS_DOUBLE) {
                     index = (long)Z_DVAL_P(offset);
              } else {
                     index = Z_LVAL_P(offset);
              }
              if (zend_hash_index_find(ht, index, (void **) &retval) == FAILURE) {
                     if (type == BP_VAR_W || type == BP_VAR_RW) {
                            zval *value;
                            ALLOC_INIT_ZVAL(value);
                            zend_hash_index_update(ht, index, (void**)&value, sizeof(void*), NULL);
                            zend_hash_index_find(ht, index, (void **) &retval);
                            return retval;
                     } else {
                            zend_error(E_NOTICE, "Undefined offset:  %ld", index);
                            return &EG(uninitialized_zval_ptr);
                     }
              } else {
                     return retval;
              }
              break;
       default:
              zend_error(E_WARNING, "Illegal offset type");
              return &EG(uninitialized_zval_ptr);
       }
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static HashTable* spl_array_get_hash_table ( spl_array_object intern,
int check_std_props  TSRMLS_DC 
) [inline, static]

Definition at line 83 of file spl_array.c.

                                                                                                           { /* {{{ */
       if ((intern->ar_flags & SPL_ARRAY_IS_SELF) != 0) {
              return intern->std.properties;
       } else if ((intern->ar_flags & SPL_ARRAY_USE_OTHER) && (check_std_props == 0 || (intern->ar_flags & SPL_ARRAY_STD_PROP_LIST) == 0) && Z_TYPE_P(intern->array) == IS_OBJECT) {
              spl_array_object *other  = (spl_array_object*)zend_object_store_get_object(intern->array TSRMLS_CC);
              return spl_array_get_hash_table(other, check_std_props TSRMLS_CC);
       } else if ((intern->ar_flags & ((check_std_props ? SPL_ARRAY_STD_PROP_LIST : 0) | SPL_ARRAY_IS_SELF)) != 0) {
              return intern->std.properties;
       } else {
              return HASH_OF(intern->array);
       }
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

zend_object_iterator * spl_array_get_iterator ( zend_class_entry *  ce,
zval *  object,
int by_ref  TSRMLS_DC 
)

Definition at line 1087 of file spl_array.c.

{
       spl_array_it       *iterator;
       spl_array_object   *array_object = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);

       if (by_ref && (array_object->ar_flags & SPL_ARRAY_OVERLOADED_CURRENT)) {
              zend_error(E_ERROR, "An iterator cannot be used with foreach by reference");
       }

       iterator     = emalloc(sizeof(spl_array_it));

       Z_ADDREF_P(object);
       iterator->intern.it.data = (void*)object;
       iterator->intern.it.funcs = &spl_array_it_funcs;
       iterator->intern.ce = ce;
       iterator->intern.value = NULL;
       iterator->object = array_object;
       
       return (zend_object_iterator*)iterator;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static HashTable* spl_array_get_properties ( zval *object  TSRMLS_DC) [static]

Definition at line 729 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       HashTable *result;

       if (intern->nApplyCount > 1) {
              php_error_docref(NULL TSRMLS_CC, E_ERROR, "Nesting level too deep - recursive dependency?");
       }

       intern->nApplyCount++;
       result = spl_array_get_hash_table(intern, 1 TSRMLS_CC);
       intern->nApplyCount--;
       return result;
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static zval** spl_array_get_property_ptr_ptr ( zval *  object,
zval *member  TSRMLS_DC 
) [static]

Definition at line 803 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);

       if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
       && !std_object_handlers.has_property(object, member, 2 TSRMLS_CC)) {
              return spl_array_get_dimension_ptr_ptr(1, object, member, BP_VAR_RW TSRMLS_CC);
       }
       return std_object_handlers.get_property_ptr_ptr(object, member TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static int spl_array_has_dimension ( zval *  object,
zval *  offset,
int check_empty  TSRMLS_DC 
) [static]

Definition at line 628 of file spl_array.c.

{
       return spl_array_has_dimension_ex(1, object, offset, check_empty TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static int spl_array_has_dimension_ex ( int  check_inherited,
zval *  object,
zval *  offset,
int check_empty  TSRMLS_DC 
) [static]

Definition at line 560 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       long index;
       zval *rv, **tmp;

       if (check_inherited && intern->fptr_offset_has) {
              SEPARATE_ARG_IF_REF(offset);
              zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_has, "offsetExists", &rv, offset);
              zval_ptr_dtor(&offset);
              if (rv && zend_is_true(rv)) {
                     zval_ptr_dtor(&rv);
                     return 1;
              }
              if (rv) {
                     zval_ptr_dtor(&rv);
              }
              return 0;
       }
       
       switch(Z_TYPE_P(offset)) {
       case IS_STRING:
              if (check_empty) {
                     if (zend_symtable_find(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &tmp) != FAILURE) {
                            switch (check_empty) {
                                   case 0:
                                          return Z_TYPE_PP(tmp) != IS_NULL;
                                   case 2:
                                          return 1;
                                   default:
                                          return zend_is_true(*tmp);
                            }
                     }
                     return 0;
              } else {
                     return zend_symtable_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1);
              }
       case IS_DOUBLE:
       case IS_RESOURCE:
       case IS_BOOL: 
       case IS_LONG: 
              if (offset->type == IS_DOUBLE) {
                     index = (long)Z_DVAL_P(offset);
              } else {
                     index = Z_LVAL_P(offset);
              }
              if (check_empty) {
                     HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
                     if (zend_hash_index_find(ht, index, (void **)&tmp) != FAILURE) {
                            switch (check_empty) {
                                   case 0:
                                          return Z_TYPE_PP(tmp) != IS_NULL;
                                   case 2:
                                          return 1;
                                   default:
                                          return zend_is_true(*tmp);
                            }
                     }
                     return 0;
              } else {
                     return zend_hash_index_exists(spl_array_get_hash_table(intern, 0 TSRMLS_CC), index);
              }
       default:
              zend_error(E_WARNING, "Illegal offset type");
       }
       return 0;
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static int spl_array_has_property ( zval *  object,
zval *  member,
int has_set_exists  TSRMLS_DC 
) [static]

Definition at line 814 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);

       if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
       && !std_object_handlers.has_property(object, member, 2 TSRMLS_CC)) {
              return spl_array_has_dimension(object, member, has_set_exists TSRMLS_CC);
       }
       return std_object_handlers.has_property(object, member, has_set_exists TSRMLS_CC);

} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_it_dtor ( zend_object_iterator *iter  TSRMLS_DC) [static]

Definition at line 899 of file spl_array.c.

{
       spl_array_it *iterator = (spl_array_it *)iter;

       zend_user_it_invalidate_current(iter TSRMLS_CC);
       zval_ptr_dtor((zval**)&iterator->intern.it.data);

       efree(iterator);
}

Here is the call graph for this function:

static void spl_array_it_get_current_data ( zend_object_iterator *  iter,
zval ***data  TSRMLS_DC 
) [static]

Definition at line 934 of file spl_array.c.

{
       spl_array_it       *iterator = (spl_array_it *)iter;
       spl_array_object   *object   = iterator->object;
       HashTable          *aht      = spl_array_get_hash_table(object, 0 TSRMLS_CC);

       if (object->ar_flags & SPL_ARRAY_OVERLOADED_CURRENT) {
              zend_user_it_get_current_data(iter, data TSRMLS_CC);
       } else {
              if (zend_hash_get_current_data_ex(aht, (void**)data, &object->pos) == FAILURE) {
                     *data = NULL;
              }
       }
}

Here is the call graph for this function:

static int spl_array_it_get_current_key ( zend_object_iterator *  iter,
char **  str_key,
uint str_key_len,
ulong *int_key  TSRMLS_DC 
) [static]

Definition at line 950 of file spl_array.c.

{
       spl_array_it       *iterator = (spl_array_it *)iter;
       spl_array_object   *object   = iterator->object;
       HashTable          *aht      = spl_array_get_hash_table(object, 0 TSRMLS_CC);

       if (object->ar_flags & SPL_ARRAY_OVERLOADED_KEY) {
              return zend_user_it_get_current_key(iter, str_key, str_key_len, int_key TSRMLS_CC);
       } else {
              if (!aht) {
                     php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::current(): Array was modified outside object and is no longer an array");
                     return HASH_KEY_NON_EXISTANT;
              }
       
              if ((object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(object, aht TSRMLS_CC) == FAILURE) {
                     php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::current(): Array was modified outside object and internal position is no longer valid");
                     return HASH_KEY_NON_EXISTANT;
              }
       
              return zend_hash_get_current_key_ex(aht, str_key, str_key_len, int_key, 1, &object->pos);
       }
}

Here is the call graph for this function:

static void spl_array_it_move_forward ( zend_object_iterator *iter  TSRMLS_DC) [static]

Definition at line 974 of file spl_array.c.

{
       spl_array_it       *iterator = (spl_array_it *)iter;
       spl_array_object   *object   = iterator->object;
       HashTable          *aht      = spl_array_get_hash_table(object, 0 TSRMLS_CC);

       if (object->ar_flags & SPL_ARRAY_OVERLOADED_NEXT) {
              zend_user_it_move_forward(iter TSRMLS_CC);
       } else {
              zend_user_it_invalidate_current(iter TSRMLS_CC);
              if (!aht) {
                     php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::current(): Array was modified outside object and is no longer an array");
                     return;
              }
       
              if ((object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(object, aht TSRMLS_CC) == FAILURE) {
                     php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::next(): Array was modified outside object and internal position is no longer valid");
              } else {
                     spl_array_next_no_verify(object, aht TSRMLS_CC);
              }
       }
}

Here is the call graph for this function:

static void spl_array_it_rewind ( zend_object_iterator *iter  TSRMLS_DC) [static]

Definition at line 1020 of file spl_array.c.

Here is the call graph for this function:

static int spl_array_it_valid ( zend_object_iterator *iter  TSRMLS_DC) [static]

Definition at line 910 of file spl_array.c.

{
       spl_array_it       *iterator = (spl_array_it *)iter;
       spl_array_object   *object   = iterator->object;
       HashTable          *aht      = spl_array_get_hash_table(object, 0 TSRMLS_CC);

       if (object->ar_flags & SPL_ARRAY_OVERLOADED_VALID) {
              return zend_user_it_valid(iter TSRMLS_CC);
       } else {
              if (!aht) {
                     php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::valid(): Array was modified outside object and is no longer an array");
                     return FAILURE;
              }
       
              if (object->pos && (object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(object, aht TSRMLS_CC) == FAILURE) {
                     php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::valid(): Array was modified outside object and internal position is no longer valid");
                     return FAILURE;
              } else {
                     return zend_hash_has_more_elements_ex(aht, &object->pos);
              }
       }
}

Here is the call graph for this function:

void spl_array_iterator_append ( zval *  object,
zval *append_value  TSRMLS_DC 
)

Definition at line 671 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);

       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              return;
       }
       
       if (Z_TYPE_P(intern->array) == IS_OBJECT) {
              php_error_docref(NULL TSRMLS_CC, E_RECOVERABLE_ERROR, "Cannot append properties to objects, use %s::offsetSet() instead", Z_OBJCE_P(object)->name);
              return;
       }

       spl_array_write_dimension(object, NULL, append_value TSRMLS_CC);
       if (!intern->pos) {
              spl_array_set_pos(intern, aht->pListTail);
       }
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

void spl_array_iterator_key ( zval *  object,
zval *return_value  TSRMLS_DC 
)

Definition at line 1478 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       char *string_key;
       uint string_length;
       ulong num_key;
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);

       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              return;
       }

       if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid");
              return;
       }

       switch (zend_hash_get_current_key_ex(aht, &string_key, &string_length, &num_key, 1, &intern->pos)) {
              case HASH_KEY_IS_STRING:
                     RETVAL_STRINGL(string_key, string_length - 1, 0);
                     break;
              case HASH_KEY_IS_LONG:
                     RETVAL_LONG(num_key);
                     break;
              case HASH_KEY_NON_EXISTANT:
                     return;
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_method ( INTERNAL_FUNCTION_PARAMETERS  ,
char *  fname,
int  fname_len,
int  use_arg 
) [static]

Definition at line 1368 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
       zval *tmp, *arg;
       zval *retval_ptr = NULL;
       
       MAKE_STD_ZVAL(tmp);
       Z_TYPE_P(tmp) = IS_ARRAY;
       Z_ARRVAL_P(tmp) = aht;
       
       if (use_arg) {
              if (ZEND_NUM_ARGS() != 1 || zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
                     Z_TYPE_P(tmp) = IS_NULL;
                     zval_ptr_dtor(&tmp);
                     zend_throw_exception(spl_ce_BadMethodCallException, "Function expects exactly one argument", 0 TSRMLS_CC);
                     return;
              }
              aht->nApplyCount++;
              zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 2, tmp, arg TSRMLS_CC);
              aht->nApplyCount--;
       } else {
              aht->nApplyCount++;
              zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 1, tmp, NULL TSRMLS_CC);
              aht->nApplyCount--;
       }
       Z_TYPE_P(tmp) = IS_NULL; /* we want to destroy the zval, not the hashtable */
       zval_ptr_dtor(&tmp);
       if (retval_ptr) {
              COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
       }
} /* }}} */

Here is the call graph for this function:

SPL_ARRAY_METHOD ( SPL_ARRAY_METHOD Array,
asort  ,
 
)

Definition at line 1410 of file spl_array.c.

{
       zval *object = getThis();
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       zval **entry;
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
       
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              return;
       }

       if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid");
              return;
       }

       if (zend_hash_get_current_data_ex(aht, (void **) &entry, &intern->pos) == FAILURE) {
              return;
       }
       RETVAL_ZVAL(*entry, 1, 0);
}

Here is the call graph for this function:

static int spl_array_next ( spl_array_object *intern  TSRMLS_DC) [static]

Definition at line 885 of file spl_array.c.

{
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);

       return spl_array_next_ex(intern, aht TSRMLS_CC);

} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static int spl_array_next_ex ( spl_array_object intern,
HashTable *aht  TSRMLS_DC 
) [static]

Definition at line 875 of file spl_array.c.

{
       if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid");
              return FAILURE;
       }

       return spl_array_next_no_verify(intern, aht TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static int spl_array_next_no_verify ( spl_array_object intern,
HashTable *aht  TSRMLS_DC 
) [static]

Definition at line 864 of file spl_array.c.

{
       zend_hash_move_forward_ex(aht, &intern->pos);
       spl_array_update_pos(intern);
       if (Z_TYPE_P(intern->array) == IS_OBJECT) {
              return spl_array_skip_protected(intern, aht TSRMLS_CC);
       } else {
              return zend_hash_has_more_elements_ex(aht, &intern->pos);
       }
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static zend_object_value spl_array_object_clone ( zval *zobject  TSRMLS_DC) [static]

Definition at line 290 of file spl_array.c.

{
       zend_object_value new_obj_val;
       zend_object *old_object;
       zend_object *new_object;
       zend_object_handle handle = Z_OBJ_HANDLE_P(zobject);
       spl_array_object *intern;

       old_object = zend_objects_get_address(zobject TSRMLS_CC);
       new_obj_val = spl_array_object_new_ex(old_object->ce, &intern, zobject, 1 TSRMLS_CC);
       new_object = &intern->std;

       zend_objects_clone_members(new_object, new_obj_val, old_object, handle TSRMLS_CC);

       return new_obj_val;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int spl_array_object_count_elements ( zval *  object,
long *count  TSRMLS_DC 
)

Definition at line 1330 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);

       if (intern->fptr_count) {
              zval *rv;
              zend_call_method_with_0_params(&object, intern->std.ce, &intern->fptr_count, "count", &rv);
              if (rv) {
                     zval_ptr_dtor(&intern->retval);
                     MAKE_STD_ZVAL(intern->retval);
                     ZVAL_ZVAL(intern->retval, rv, 1, 1);
                     convert_to_long(intern->retval);
                     *count = (long) Z_LVAL_P(intern->retval);
                     return SUCCESS;
              }
              *count = 0;
              return FAILURE;
       }
       return spl_array_object_count_elements_helper(intern, count TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static int spl_array_object_count_elements_helper ( spl_array_object intern,
long *count  TSRMLS_DC 
) [static]

Definition at line 1302 of file spl_array.c.

{
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
       HashPosition pos;

       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              *count = 0;
              return FAILURE;
       }

       if (Z_TYPE_P(intern->array) == IS_OBJECT) {
              /* We need to store the 'pos' since we'll modify it in the functions 
               * we're going to call and which do not support 'pos' as parameter. */
              pos = intern->pos;
              *count = 0;
              spl_array_rewind(intern TSRMLS_CC);
              while(intern->pos && spl_array_next(intern TSRMLS_CC) == SUCCESS) {
                     (*count)++;
              }
              spl_array_set_pos(intern, pos);
              return SUCCESS;
       } else {
              *count = zend_hash_num_elements(aht);
              return SUCCESS;
       }
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_object_free_storage ( void *object  TSRMLS_DC) [static]

Definition at line 140 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object *)object;

       zend_object_std_dtor(&intern->std TSRMLS_CC);

       zval_ptr_dtor(&intern->array);
       zval_ptr_dtor(&intern->retval);

       if (intern->debug_info != NULL) {
              zend_hash_destroy(intern->debug_info);
              efree(intern->debug_info);
       }

       efree(object);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static zend_object_value spl_array_object_new ( zend_class_entry *class_type  TSRMLS_DC) [static]

Definition at line 282 of file spl_array.c.

{
       spl_array_object *tmp;
       return spl_array_object_new_ex(class_type, &tmp, NULL, 0 TSRMLS_CC);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static zend_object_value spl_array_object_new_ex ( zend_class_entry *  class_type,
spl_array_object **  obj,
zval *  orig,
int clone_orig  TSRMLS_DC 
) [static]

Definition at line 163 of file spl_array.c.

{
       zend_object_value retval;
       spl_array_object *intern;
       zval *tmp;
       zend_class_entry * parent = class_type;
       int inherited = 0;

       intern = emalloc(sizeof(spl_array_object));
       memset(intern, 0, sizeof(spl_array_object));
       *obj = intern;
       ALLOC_INIT_ZVAL(intern->retval);

       zend_object_std_init(&intern->std, class_type TSRMLS_CC);
       zend_hash_copy(intern->std.properties, &class_type->default_properties, (copy_ctor_func_t) zval_add_ref, (void *) &tmp, sizeof(zval *));

       intern->ar_flags = 0;
       intern->serialize_data   = NULL;
       intern->unserialize_data = NULL;
       intern->debug_info       = NULL;
       intern->ce_get_iterator = spl_ce_ArrayIterator;
       if (orig) {
              spl_array_object *other = (spl_array_object*)zend_object_store_get_object(orig TSRMLS_CC);

              intern->ar_flags &= ~ SPL_ARRAY_CLONE_MASK;
              intern->ar_flags |= (other->ar_flags & SPL_ARRAY_CLONE_MASK);
              intern->ce_get_iterator = other->ce_get_iterator;
              if (clone_orig) {
                     intern->array = other->array;
                     if (Z_OBJ_HT_P(orig) == &spl_handler_ArrayObject) {
                            MAKE_STD_ZVAL(intern->array);
                            array_init(intern->array);
                            zend_hash_copy(HASH_OF(intern->array), HASH_OF(other->array), (copy_ctor_func_t) zval_add_ref, &tmp, sizeof(zval*));
                     }
                     if (Z_OBJ_HT_P(orig) == &spl_handler_ArrayIterator) {
                            Z_ADDREF_P(other->array);
                     }
              } else {
                     intern->array = orig;
                     Z_ADDREF_P(intern->array);
                     intern->ar_flags |= SPL_ARRAY_IS_REF | SPL_ARRAY_USE_OTHER;
              }
       } else {
              MAKE_STD_ZVAL(intern->array);
              array_init(intern->array);
              intern->ar_flags &= ~SPL_ARRAY_IS_REF;
       }

       retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t)zend_objects_destroy_object, (zend_objects_free_object_storage_t) spl_array_object_free_storage, NULL TSRMLS_CC);
       while (parent) {
              if (parent == spl_ce_ArrayIterator || parent == spl_ce_RecursiveArrayIterator) {
                     retval.handlers = &spl_handler_ArrayIterator;
                     class_type->get_iterator = spl_array_get_iterator;
                     break;
              } else if (parent == spl_ce_ArrayObject) {
                     retval.handlers = &spl_handler_ArrayObject;
                     break;
              }
              parent = parent->parent;
              inherited = 1;
       }
       if (!parent) { /* this must never happen */
              php_error_docref(NULL TSRMLS_CC, E_COMPILE_ERROR, "Internal compiler error, Class is not child of ArrayObject or ArrayIterator");
       }
       if (inherited) {
              zend_hash_find(&class_type->function_table, "offsetget",    sizeof("offsetget"),    (void **) &intern->fptr_offset_get);
              if (intern->fptr_offset_get->common.scope == parent) {
                     intern->fptr_offset_get = NULL;
              }
              zend_hash_find(&class_type->function_table, "offsetset",    sizeof("offsetset"),    (void **) &intern->fptr_offset_set);
              if (intern->fptr_offset_set->common.scope == parent) {
                     intern->fptr_offset_set = NULL;
              }
              zend_hash_find(&class_type->function_table, "offsetexists", sizeof("offsetexists"), (void **) &intern->fptr_offset_has);
              if (intern->fptr_offset_has->common.scope == parent) {
                     intern->fptr_offset_has = NULL;
              }
              zend_hash_find(&class_type->function_table, "offsetunset",  sizeof("offsetunset"),  (void **) &intern->fptr_offset_del);
              if (intern->fptr_offset_del->common.scope == parent) {
                     intern->fptr_offset_del = NULL;
              }
              zend_hash_find(&class_type->function_table, "count",        sizeof("count"),        (void **) &intern->fptr_count);
              if (intern->fptr_count->common.scope == parent) {
                     intern->fptr_count = NULL;
              }
              zend_hash_find(&class_type->function_table, "serialize",    sizeof("serialize"),    (void **) &intern->fptr_serialize);
              if (intern->fptr_serialize->common.scope == parent) {
                     intern->fptr_serialize = NULL;
              }
              zend_hash_find(&class_type->function_table, "unserialize",  sizeof("unserialize"),  (void **) &intern->fptr_unserialize);
              if (intern->fptr_unserialize->common.scope == parent) {
                     intern->fptr_unserialize = NULL;
              }
       }
       /* Cache iterator functions if ArrayIterator or derived. Check current's */
       /* cache since only current is always required */
       if (retval.handlers == &spl_handler_ArrayIterator) {
              if (!class_type->iterator_funcs.zf_current) {
                     zend_hash_find(&class_type->function_table, "rewind",  sizeof("rewind"),  (void **) &class_type->iterator_funcs.zf_rewind);
                     zend_hash_find(&class_type->function_table, "valid",   sizeof("valid"),   (void **) &class_type->iterator_funcs.zf_valid);
                     zend_hash_find(&class_type->function_table, "key",     sizeof("key"),     (void **) &class_type->iterator_funcs.zf_key);
                     zend_hash_find(&class_type->function_table, "current", sizeof("current"), (void **) &class_type->iterator_funcs.zf_current);
                     zend_hash_find(&class_type->function_table, "next",    sizeof("next"),    (void **) &class_type->iterator_funcs.zf_next);
              }
              if (inherited) {
                     if (class_type->iterator_funcs.zf_rewind->common.scope  != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_REWIND;
                     if (class_type->iterator_funcs.zf_valid->common.scope   != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_VALID;
                     if (class_type->iterator_funcs.zf_key->common.scope     != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_KEY;
                     if (class_type->iterator_funcs.zf_current->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_CURRENT;
                     if (class_type->iterator_funcs.zf_next->common.scope    != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_NEXT;
              }
       }

       spl_array_rewind(intern TSRMLS_CC);
       return retval;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static zval* spl_array_read_dimension ( zval *  object,
zval *  offset,
int type  TSRMLS_DC 
) [static]

Definition at line 421 of file spl_array.c.

{
       return spl_array_read_dimension_ex(1, object, offset, type TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static zval* spl_array_read_dimension_ex ( int  check_inherited,
zval *  object,
zval *  offset,
int type  TSRMLS_DC 
) [static]

Definition at line 375 of file spl_array.c.

{
       zval **ret;

       if (check_inherited) {
              spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
              if (intern->fptr_offset_get) {
                     zval *rv;
                     SEPARATE_ARG_IF_REF(offset);
                     zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_get, "offsetGet", &rv, offset); 
                     zval_ptr_dtor(&offset);
                     if (rv) {
                            zval_ptr_dtor(&intern->retval);
                            MAKE_STD_ZVAL(intern->retval);
                            ZVAL_ZVAL(intern->retval, rv, 1, 1);
                            return intern->retval;
                     }
                     return EG(uninitialized_zval_ptr);
              }
       }
       ret = spl_array_get_dimension_ptr_ptr(check_inherited, object, offset, type TSRMLS_CC);

       /* When in a write context,
        * ZE has to be fooled into thinking this is in a reference set
        * by separating (if necessary) and returning as an is_ref=1 zval (even if refcount == 1) */
       if ((type == BP_VAR_W || type == BP_VAR_RW) && !Z_ISREF_PP(ret)) {
              if (Z_REFCOUNT_PP(ret) > 1) {
                     zval *newval;

                     /* Separate */
                     MAKE_STD_ZVAL(newval);
                     *newval = **ret;
                     zval_copy_ctor(newval);
                     Z_SET_REFCOUNT_P(newval, 1);

                     /* Replace */
                     Z_DELREF_PP(ret);
                     *ret = newval;
              }

              Z_SET_ISREF_PP(ret);
       }

       return *ret;
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static zval* spl_array_read_property ( zval *  object,
zval *  member,
int type  TSRMLS_DC 
) [static]

Definition at line 780 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);

       if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
       && !std_object_handlers.has_property(object, member, 2 TSRMLS_CC)) {
              return spl_array_read_dimension(object, member, type TSRMLS_CC);
       }
       return std_object_handlers.read_property(object, member, type TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_rewind ( spl_array_object *intern  TSRMLS_DC) [static]

Definition at line 1007 of file spl_array.c.

{
       HashTable          *aht      = spl_array_get_hash_table(intern, 0 TSRMLS_CC);

       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "ArrayIterator::rewind(): Array was modified outside object and is no longer an array");
              return;
       }

       spl_array_rewind_ex(intern, aht TSRMLS_CC);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_rewind_ex ( spl_array_object intern,
HashTable *aht  TSRMLS_DC 
) [static]

Definition at line 998 of file spl_array.c.

Here is the call graph for this function:

Here is the caller graph for this function:

int spl_array_serialize ( zval *  object,
unsigned char **  buffer,
zend_uint buf_len,
zend_serialize_data *data  TSRMLS_DC 
)

Definition at line 1698 of file spl_array.c.

{
       spl_array_object     *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);

       if (intern->fptr_serialize) {
              int retval;
              php_serialize_data_t *before;

              before = intern->serialize_data;
              intern->serialize_data = (php_serialize_data_t *)data;

              retval = zend_user_serialize(object, buffer, buf_len, data TSRMLS_CC);

              intern->serialize_data = before;

              return retval;
       } else {
              smart_str buf;

              buf = spl_array_serialize_helper(intern, (php_serialize_data_t *)data TSRMLS_CC);

              if (buf.c) {
                     *buffer  = (unsigned char*)estrndup(buf.c, buf.len);
                     *buf_len = buf.len;
                     efree(buf.c);
                     return SUCCESS;
              } else {
                     return FAILURE;
              }
       }
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 1628 of file spl_array.c.

                                                                                                           { /* {{{ */
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
       zval members, *pmembers;
       smart_str buf = {0};
       zval *flags;
       
       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              return buf;
       }

       MAKE_STD_ZVAL(flags);
       ZVAL_LONG(flags, (intern->ar_flags & SPL_ARRAY_CLONE_MASK));

       /* storage */
       smart_str_appendl(&buf, "x:", 2);
       php_var_serialize(&buf, &flags, var_hash_p TSRMLS_CC);
       zval_ptr_dtor(&flags);

       if (!(intern->ar_flags & SPL_ARRAY_IS_SELF)) {
              php_var_serialize(&buf, &intern->array, var_hash_p TSRMLS_CC);
              smart_str_appendc(&buf, ';');
       }

       /* members */
       smart_str_appendl(&buf, "m:", 2);
       INIT_PZVAL(&members);
       Z_ARRVAL(members) = intern->std.properties;
       Z_TYPE(members) = IS_ARRAY;
       pmembers = &members;
       php_var_serialize(&buf, &pmembers, var_hash_p TSRMLS_CC); /* finishes the string */

       /* done */
       return buf;
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_set_array ( zval *  object,
spl_array_object intern,
zval **  array,
long  ar_flags,
int just_array  TSRMLS_DC 
) [static]

Definition at line 1035 of file spl_array.c.

                                                                                                                               {

       if (Z_TYPE_PP(array) == IS_ARRAY) {
              SEPARATE_ZVAL_IF_NOT_REF(array);
       }

       if (Z_TYPE_PP(array) == IS_OBJECT && (Z_OBJ_HT_PP(array) == &spl_handler_ArrayObject || Z_OBJ_HT_PP(array) == &spl_handler_ArrayIterator)) {
              zval_ptr_dtor(&intern->array);
              if (just_array)      {
                     spl_array_object *other = (spl_array_object*)zend_object_store_get_object(*array TSRMLS_CC);
                     ar_flags = other->ar_flags & ~SPL_ARRAY_INT_MASK;
              }             
              ar_flags |= SPL_ARRAY_USE_OTHER;
              intern->array = *array;
       } else {
              if (Z_TYPE_PP(array) != IS_OBJECT && Z_TYPE_PP(array) != IS_ARRAY) {
                     zend_throw_exception(spl_ce_InvalidArgumentException, "Passed variable is not an array or object, using empty array instead", 0 TSRMLS_CC);
                     return;
              }
              zval_ptr_dtor(&intern->array);
              intern->array = *array;
       }
       if (object == *array) {
              intern->ar_flags |= SPL_ARRAY_IS_SELF;
              intern->ar_flags &= ~SPL_ARRAY_USE_OTHER;
       } else {
              intern->ar_flags &= ~SPL_ARRAY_IS_SELF;
       }
       intern->ar_flags |= ar_flags;
       Z_ADDREF_P(intern->array);
       if (Z_TYPE_PP(array) == IS_OBJECT) {
              zend_object_get_properties_t handler = Z_OBJ_HANDLER_PP(array, get_properties);
              if ((handler != std_object_handlers.get_properties && handler != spl_array_get_properties)
              || !spl_array_get_hash_table(intern, 0 TSRMLS_CC)) {
                     zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Overloaded object of type %s is not compatible with %s", Z_OBJCE_PP(array)->name, intern->std.ce->name);
              }
       }

       spl_array_rewind(intern TSRMLS_CC);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_set_pos ( spl_array_object intern,
HashPosition  pos 
) [static]

Definition at line 106 of file spl_array.c.

{
       intern->pos = pos;
       spl_array_update_pos(intern);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static int spl_array_skip_protected ( spl_array_object intern,
HashTable *aht  TSRMLS_DC 
) [static]

Definition at line 839 of file spl_array.c.

{
       char *string_key;
       uint string_length;
       ulong num_key;

       if (Z_TYPE_P(intern->array) == IS_OBJECT) {
              do {
                     if (zend_hash_get_current_key_ex(aht, &string_key, &string_length, &num_key, 0, &intern->pos) == HASH_KEY_IS_STRING) {
                            if (!string_length || string_key[0]) {
                                   return SUCCESS;
                            }
                     } else {
                            return SUCCESS;
                     }
                     if (zend_hash_has_more_elements_ex(aht, &intern->pos) != SUCCESS) {
                            return FAILURE;
                     }
                     zend_hash_move_forward_ex(aht, &intern->pos);
                     spl_array_update_pos(intern);
              } while (1);
       }
       return FAILURE;
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

int spl_array_unserialize ( zval **  object,
zend_class_entry *  ce,
const unsigned char *  buf,
zend_uint  buf_len,
zend_unserialize_data *data  TSRMLS_DC 
)

Definition at line 1839 of file spl_array.c.

{
       spl_array_object *intern;

       object_init_ex(*object, ce);
       intern = (spl_array_object*)zend_object_store_get_object(*object TSRMLS_CC);

       if (intern->fptr_unserialize) {
              zval *zdata;
              php_unserialize_data_t *before;
              MAKE_STD_ZVAL(zdata);
              ZVAL_STRINGL(zdata, (char *)buf, buf_len, 1);

              before = intern->unserialize_data;
              intern->unserialize_data = (php_unserialize_data_t *)data;

              zend_call_method_with_1_params(object, ce, &ce->unserialize_func, "unserialize", NULL, zdata);

              intern->unserialize_data = before;

              zval_ptr_dtor(&zdata);
       } else {
              spl_array_unserialize_helper(intern, buf, buf_len, (php_unserialize_data_t *)data TSRMLS_CC);
       }

       if (EG(exception)) {
              return FAILURE;
       } else {
              return SUCCESS;
       }
} 

Here is the call graph for this function:

Here is the caller graph for this function:

void spl_array_unserialize_helper ( spl_array_object intern,
const unsigned char *  buf,
int  buf_len,
php_unserialize_data_t *var_hash_p  TSRMLS_DC 
)

Definition at line 1731 of file spl_array.c.

{
       const unsigned char *p, *s;
       zval *pmembers, *pflags = NULL;
       long flags;

       /* storage */
       s = p = buf;

       if (*p!= 'x' || *++p != ':') {
              goto outexcept;
       }
       ++p;

       ALLOC_INIT_ZVAL(pflags);
       if (!php_var_unserialize(&pflags, &p, s + buf_len, var_hash_p TSRMLS_CC) || Z_TYPE_P(pflags) != IS_LONG) {
              zval_ptr_dtor(&pflags);
              goto outexcept;
       }

       --p; /* for ';' */
       flags = Z_LVAL_P(pflags);
       zval_ptr_dtor(&pflags);
       /* flags needs to be verified and we also need to verify whether the next
        * thing we get is ';'. After that we require an 'm' or somethign else
        * where 'm' stands for members and anything else should be an array. If
        * neither 'a' or 'm' follows we have an error. */

       if (*p != ';') {
              goto outexcept;
       }
       ++p;

       if (*p!='m') {
              if (*p!='a' && *p!='O' && *p!='C') {
                     goto outexcept;
              }
              intern->ar_flags &= ~SPL_ARRAY_CLONE_MASK;
              intern->ar_flags |= flags & SPL_ARRAY_CLONE_MASK;
              zval_ptr_dtor(&intern->array);
              ALLOC_INIT_ZVAL(intern->array);
              if (!php_var_unserialize(&intern->array, &p, s + buf_len, var_hash_p TSRMLS_CC)) {
                     goto outexcept;
              }
       }
       if (*p != ';') {
              goto outexcept;
       }
       ++p;

       /* members */
       if (*p!= 'm' || *++p != ':') {
              goto outexcept;
       }
       ++p;

       ALLOC_INIT_ZVAL(pmembers);
       if (!php_var_unserialize(&pmembers, &p, s + buf_len, var_hash_p TSRMLS_CC)) {
              zval_ptr_dtor(&pmembers);
              goto outexcept;
       }

       /* copy members */
       zend_hash_copy(intern->std.properties, Z_ARRVAL_P(pmembers), (copy_ctor_func_t) zval_add_ref, (void *) NULL, sizeof(zval *));
       zval_ptr_dtor(&pmembers);

       /* done reading $serialized */
       return;

outexcept:
       zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Error at offset %ld of %d bytes", (long)((char*)p - (char *)buf), buf_len);
       return;

}

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_unset_dimension ( zval *  object,
zval *offset  TSRMLS_DC 
) [static]

Definition at line 555 of file spl_array.c.

{
       spl_array_unset_dimension_ex(1, object, offset TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_unset_dimension_ex ( int  check_inherited,
zval *  object,
zval *offset  TSRMLS_DC 
) [static]

Definition at line 500 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       long index;
       HashTable *ht;

       if (check_inherited && intern->fptr_offset_del) {
              SEPARATE_ARG_IF_REF(offset);
              zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_del, "offsetUnset", NULL, offset);
              zval_ptr_dtor(&offset);
              return;
       }

       switch(Z_TYPE_P(offset)) {
       case IS_STRING:
              ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
              if (ht->nApplyCount > 0) {
                     zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                     return;
              }
              if (ht == &EG(symbol_table)) {
                     if (zend_delete_global_variable(Z_STRVAL_P(offset), Z_STRLEN_P(offset) TSRMLS_CC)) {
                            zend_error(E_NOTICE,"Undefined index:  %s", Z_STRVAL_P(offset));
                     }
              } else {
                     if (zend_symtable_del(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1) == FAILURE) {
                            zend_error(E_NOTICE,"Undefined index:  %s", Z_STRVAL_P(offset));
                     }
              }
              break;
       case IS_DOUBLE:
       case IS_RESOURCE:
       case IS_BOOL: 
       case IS_LONG: 
              if (offset->type == IS_DOUBLE) {
                     index = (long)Z_DVAL_P(offset);
              } else {
                     index = Z_LVAL_P(offset);
              }
              ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
              if (ht->nApplyCount > 0) {
                     zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                     return;
              }
              if (zend_hash_index_del(ht, index) == FAILURE) {
                     zend_error(E_NOTICE,"Undefined offset:  %ld", Z_LVAL_P(offset));
              }
              break;
       default:
              zend_error(E_WARNING, "Illegal offset type");
              return;
       }
       spl_hash_verify_pos(intern TSRMLS_CC); /* call rewind on FAILURE */
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_unset_property ( zval *  object,
zval *member  TSRMLS_DC 
) [static]

Definition at line 826 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);

       if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
       && !std_object_handlers.has_property(object, member, 2 TSRMLS_CC)) {
              spl_array_unset_dimension(object, member TSRMLS_CC);
              spl_array_rewind(intern TSRMLS_CC); /* because deletion might invalidate position */
              return;
       }
       std_object_handlers.unset_property(object, member TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_update_pos ( spl_array_object intern) [static]

Definition at line 98 of file spl_array.c.

{
       Bucket *pos = intern->pos;
       if (pos != NULL) {
              intern->pos_h = pos->h;
       }
} /* }}} */

Here is the caller graph for this function:

static void spl_array_write_dimension ( zval *  object,
zval *  offset,
zval *value  TSRMLS_DC 
) [static]

Definition at line 495 of file spl_array.c.

{
       spl_array_write_dimension_ex(1, object, offset, value TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_write_dimension_ex ( int  check_inherited,
zval *  object,
zval *  offset,
zval *value  TSRMLS_DC 
) [static]

Definition at line 426 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       long index;
       HashTable *ht;

       if (check_inherited && intern->fptr_offset_set) {
              if (!offset) {
                     ALLOC_INIT_ZVAL(offset);
              } else {
                     SEPARATE_ARG_IF_REF(offset);
              }
              zend_call_method_with_2_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_set, "offsetSet", NULL, offset, value);
              zval_ptr_dtor(&offset);
              return;
       }
       
       if (!offset) {
              ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
              if (ht->nApplyCount > 0) {
                     zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                     return;
              }
              Z_ADDREF_P(value);
              zend_hash_next_index_insert(ht, (void**)&value, sizeof(void*), NULL);
              return;
       }
       switch(Z_TYPE_P(offset)) {
       case IS_STRING:
              ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
              if (ht->nApplyCount > 0) {
                     zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                     return;
              }
              Z_ADDREF_P(value);
              zend_symtable_update(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void**)&value, sizeof(void*), NULL);
              return;
       case IS_DOUBLE:
       case IS_RESOURCE:
       case IS_BOOL: 
       case IS_LONG: 
              ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
              if (ht->nApplyCount > 0) {
                     zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                     return;
              }
              if (offset->type == IS_DOUBLE) {
                     index = (long)Z_DVAL_P(offset);
              } else {
                     index = Z_LVAL_P(offset);
              }
              Z_ADDREF_P(value);
              zend_hash_index_update(ht, index, (void**)&value, sizeof(void*), NULL);
              return;
       case IS_NULL:
              ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
              if (ht->nApplyCount > 0) {
                     zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
                     return;
              }
              Z_ADDREF_P(value);
              zend_hash_next_index_insert(ht, (void**)&value, sizeof(void*), NULL);
              return;
       default:
              zend_error(E_WARNING, "Illegal offset type");
              return;
       }
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

static void spl_array_write_property ( zval *  object,
zval *  member,
zval *value  TSRMLS_DC 
) [static]

Definition at line 791 of file spl_array.c.

{
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);

       if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
       && !std_object_handlers.has_property(object, member, 2 TSRMLS_CC)) {
              spl_array_write_dimension(object, member, value TSRMLS_CC);
              return;
       }
       std_object_handlers.write_property(object, member, value TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 132 of file spl_array.c.

Here is the call graph for this function:

Here is the caller graph for this function:

SPL_API int spl_hash_verify_pos_ex ( spl_array_object intern,
HashTable *ht  TSRMLS_DC 
)

Definition at line 112 of file spl_array.c.

{
       Bucket *p;

/*     IS_CONSISTENT(ht);*/

/*     HASH_PROTECT_RECURSION(ht);*/
       p = ht->arBuckets[intern->pos_h & ht->nTableMask];
       while (p != NULL) {
              if (p == intern->pos) {
                     return SUCCESS;
              }
              p = p->pNext;
       }
/*     HASH_UNPROTECT_RECURSION(ht); */
       spl_array_rewind(intern TSRMLS_CC);
       return FAILURE;

} /* }}} */

Here is the call graph for this function:

Here is the caller graph for this function:

SPL_METHOD ( Array  ,
offsetExists   
)

Definition at line 636 of file spl_array.c.

{
       zval *index;
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) {
              return;
       }
       RETURN_BOOL(spl_array_has_dimension_ex(0, getThis(), index, 0 TSRMLS_CC));
} /* }}} */

Here is the call graph for this function:

SPL_METHOD ( Array  ,
offsetGet   
)

Definition at line 648 of file spl_array.c.

{
       zval *index, *value;
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) {
              return;
       }
       value = spl_array_read_dimension_ex(0, getThis(), index, BP_VAR_R TSRMLS_CC);
       RETURN_ZVAL(value, 1, 0);
} /* }}} */

Here is the call graph for this function:

SPL_METHOD ( Array  ,
offsetSet   
)

Definition at line 661 of file spl_array.c.

{
       zval *index, *value;
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zz", &index, &value) == FAILURE) {
              return;
       }
       spl_array_write_dimension_ex(0, getThis(), index, value TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

SPL_METHOD ( Array  ,
append   
)

Definition at line 695 of file spl_array.c.

{
       zval *value;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &value) == FAILURE) {
              return;
       }
       spl_array_iterator_append(getThis(), value TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

SPL_METHOD ( Array  ,
offsetUnset   
)

Definition at line 708 of file spl_array.c.

{
       zval *index;
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &index) == FAILURE) {
              return;
       }
       spl_array_unset_dimension_ex(0, getThis(), index TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

SPL_METHOD ( Array  ,
getArrayCopy   
)

Definition at line 720 of file spl_array.c.

{
       zval *object = getThis(), *tmp;
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
    
    array_init(return_value);
       zend_hash_copy(HASH_OF(return_value), spl_array_get_hash_table(intern, 0 TSRMLS_CC), (copy_ctor_func_t) zval_add_ref, &tmp, sizeof(zval*));
} /* }}} */

Here is the call graph for this function:

SPL_METHOD ( Array  ,
__construct   
)

Definition at line 1112 of file spl_array.c.

{
       zval *object = getThis();
       spl_array_object *intern;
       zval **array;
       long ar_flags = 0;
       zend_class_entry *ce_get_iterator = spl_ce_Iterator;
       zend_error_handling error_handling;

       if (ZEND_NUM_ARGS() == 0) {
              return; /* nothing to do */
       }

       zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);

       intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|lC", &array, &ar_flags, &ce_get_iterator) == FAILURE) {
              zend_restore_error_handling(&error_handling TSRMLS_CC);
              return;
       }

       if (ZEND_NUM_ARGS() > 2) {
              intern->ce_get_iterator = ce_get_iterator;
       }

       ar_flags &= ~SPL_ARRAY_INT_MASK;

       spl_array_set_array(object, intern, array, ar_flags, ZEND_NUM_ARGS() == 1 TSRMLS_CC);

       zend_restore_error_handling(&error_handling TSRMLS_CC);

}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
setIteratorClass   
)

Definition at line 1149 of file spl_array.c.

{
       zval *object = getThis();
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       zend_class_entry * ce_get_iterator = spl_ce_Iterator;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "C", &ce_get_iterator) == FAILURE) {
              return;
       }

       intern->ce_get_iterator = ce_get_iterator;
}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
getIteratorClass   
)

Definition at line 1165 of file spl_array.c.

{
       zval *object = getThis();
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       RETURN_STRING(intern->ce_get_iterator->name, 1);
}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
getFlags   
)

Definition at line 1180 of file spl_array.c.

Here is the call graph for this function:

SPL_METHOD ( Array  ,
setFlags   
)

Definition at line 1195 of file spl_array.c.

{
       zval *object = getThis();
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       long ar_flags = 0;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ar_flags) == FAILURE) {
              return;
       }
       
       intern->ar_flags = (intern->ar_flags & SPL_ARRAY_INT_MASK) | (ar_flags & ~SPL_ARRAY_INT_MASK);
}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
exchangeArray   
)

Definition at line 1211 of file spl_array.c.

{
       zval *object = getThis(), *tmp, **array;
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);

       array_init(return_value);
       zend_hash_copy(HASH_OF(return_value), spl_array_get_hash_table(intern, 0 TSRMLS_CC), (copy_ctor_func_t) zval_add_ref, &tmp, sizeof(zval*));
       
       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &array) == FAILURE) {
              return;
       }

       spl_array_set_array(object, intern, array, 0L, 1 TSRMLS_CC);

}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
getIterator   
)

Definition at line 1230 of file spl_array.c.

{
       zval *object = getThis();
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       spl_array_object *iterator;
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
       
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              return;
       }

       return_value->type = IS_OBJECT;
       return_value->value.obj = spl_array_object_new_ex(intern->ce_get_iterator, &iterator, object, 0 TSRMLS_CC);
       Z_SET_REFCOUNT_P(return_value, 1);
       Z_SET_ISREF_P(return_value);
}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
rewind   
)

Definition at line 1255 of file spl_array.c.

{
       zval *object = getThis();
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       spl_array_rewind(intern TSRMLS_CC);
}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
seek   
)

Definition at line 1270 of file spl_array.c.

{
       long opos, position;
       zval *object = getThis();
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
       int result;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &position) == FAILURE) {
              return;
       }

       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              return;
       }

       opos = position;

       if (position >= 0) { /* negative values are not supported */
              spl_array_rewind(intern TSRMLS_CC);
              result = SUCCESS;
              
              while (position-- > 0 && (result = spl_array_next(intern TSRMLS_CC)) == SUCCESS);
       
              if (result == SUCCESS && zend_hash_has_more_elements_ex(aht, &intern->pos) == SUCCESS) {
                     return; /* ok */
              }
       }
       zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0 TSRMLS_CC, "Seek position %ld is out of range", opos);
} /* }}} */

Here is the call graph for this function:

SPL_METHOD ( Array  ,
count   
)

Definition at line 1354 of file spl_array.c.

Here is the call graph for this function:

SPL_METHOD ( Array  ,
key   
)

Definition at line 1469 of file spl_array.c.

{
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }
       
       spl_array_iterator_key(getThis(), return_value TSRMLS_CC);
} /* }}} */

Here is the call graph for this function:

SPL_METHOD ( Array  ,
next   
)

Definition at line 1511 of file spl_array.c.

{
       zval *object = getThis();
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);

       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }
       
       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              return;
       }

       spl_array_next_ex(intern, aht TSRMLS_CC);
}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
valid   
)

Definition at line 1532 of file spl_array.c.

{
       zval *object = getThis();
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);

       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }
       
       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              return;
       }

       if (intern->pos && (intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid");
              RETURN_FALSE;
       } else {
              RETURN_BOOL(zend_hash_has_more_elements_ex(aht, &intern->pos) == SUCCESS);
       }
}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
hasChildren   
)

Definition at line 1558 of file spl_array.c.

{
       zval *object = getThis(), **entry;
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
       
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }
       
       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              RETURN_FALSE;
       }

       if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid");
              RETURN_FALSE;
       }

       if (zend_hash_get_current_data_ex(aht, (void **) &entry, &intern->pos) == FAILURE) {
              RETURN_FALSE;
       }

       RETURN_BOOL(Z_TYPE_PP(entry) == IS_ARRAY || (Z_TYPE_PP(entry) == IS_OBJECT && (intern->ar_flags & SPL_ARRAY_CHILD_ARRAYS_ONLY) == 0));
}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
getChildren   
)

Definition at line 1588 of file spl_array.c.

{
       zval *object = getThis(), **entry, *flags;
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
       
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       if (!aht) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and is no longer an array");
              return;
       }

       if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
              php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid");
              return;
       }

       if (zend_hash_get_current_data_ex(aht, (void **) &entry, &intern->pos) == FAILURE) {
              return;
       }

       if (Z_TYPE_PP(entry) == IS_OBJECT) {
              if ((intern->ar_flags & SPL_ARRAY_CHILD_ARRAYS_ONLY) != 0) {
                     return;
              }
              if (instanceof_function(Z_OBJCE_PP(entry), Z_OBJCE_P(getThis()) TSRMLS_CC)) {
                     RETURN_ZVAL(*entry, 0, 0);
              }
       }

       MAKE_STD_ZVAL(flags);
       ZVAL_LONG(flags, SPL_ARRAY_USE_OTHER | intern->ar_flags);
       spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), &return_value, 0, *entry, flags TSRMLS_CC);
       zval_ptr_dtor(&flags);
}

Here is the call graph for this function:

SPL_METHOD ( Array  ,
serialize   
)

Definition at line 1667 of file spl_array.c.

{
       zval *object = getThis();
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
       int was_in_serialize = intern->serialize_data != NULL;
       smart_str buf;
       
       if (zend_parse_parameters_none() == FAILURE) {
              return;
       }

       if (!was_in_serialize) {
              intern->serialize_data = emalloc(sizeof(php_serialize_data_t));
              PHP_VAR_SERIALIZE_INIT(*intern->serialize_data);
       }

       buf = spl_array_serialize_helper(intern, intern->serialize_data TSRMLS_CC);

       if (!was_in_serialize) {
              PHP_VAR_SERIALIZE_DESTROY(*intern->serialize_data);
              efree(intern->serialize_data);
              intern->serialize_data = NULL;
       }

       if (buf.c) {
              RETURN_STRINGL(buf.c, buf.len, 0);
       }

       RETURN_NULL();
} /* }}} */

Here is the call graph for this function:

SPL_METHOD ( Array  ,
unserialize   
)

Definition at line 1809 of file spl_array.c.

{
       char *buf;
       int buf_len;
       spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
       int was_in_unserialize = intern->unserialize_data != NULL;

       if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &buf, &buf_len) == FAILURE) {
              return;
       }

       if (buf_len == 0) {
              zend_throw_exception_ex(spl_ce_UnexpectedValueException, 0 TSRMLS_CC, "Empty serialized string cannot be empty");
              return;
       }

       if (!was_in_unserialize) {
              intern->unserialize_data = emalloc(sizeof(php_unserialize_data_t));
              PHP_VAR_UNSERIALIZE_INIT(*intern->unserialize_data);
       }

       spl_array_unserialize_helper(intern, (const unsigned char *)buf, buf_len, intern->unserialize_data TSRMLS_CC);

       if (!was_in_unserialize) {
              PHP_VAR_UNSERIALIZE_DESTROY(*intern->unserialize_data);
              efree(intern->unserialize_data);
              intern->unserialize_data = NULL;
       }
} /* }}} */

Here is the call graph for this function:


Variable Documentation

PHPAPI zend_class_entry* spl_ce_ArrayIterator

Definition at line 44 of file spl_array.c.

PHPAPI zend_class_entry* spl_ce_ArrayObject

Definition at line 41 of file spl_array.c.

Definition at line 45 of file spl_array.c.

Initial value:

Definition at line 1944 of file spl_array.c.

Initial value:

Definition at line 1917 of file spl_array.c.

Initial value:

Definition at line 1973 of file spl_array.c.

zend_object_handlers spl_handler_ArrayIterator

Definition at line 43 of file spl_array.c.

zend_object_handlers spl_handler_ArrayObject

Definition at line 40 of file spl_array.c.