Back to index

php5  5.3.10
Functions | Variables
spl_array.h File Reference
#include "php.h"
#include "php_spl.h"
#include "spl_iterators.h"
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 PHP_MINIT_FUNCTION (spl_array)
void spl_array_iterator_append (zval *object, zval *append_value TSRMLS_DC)
void spl_array_iterator_key (zval *object, zval *return_value TSRMLS_DC)

Variables

PHPAPI zend_class_entry * spl_ce_ArrayObject
PHPAPI zend_class_entry * spl_ce_ArrayIterator
PHPAPI zend_class_entry * spl_ce_RecursiveArrayIterator

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:

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:


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.