summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
Diffstat (limited to 'ext/spl')
-rwxr-xr-xext/spl/config.m44
-rw-r--r--ext/spl/config.w322
-rwxr-xr-xext/spl/package.xml2
-rwxr-xr-xext/spl/php_spl.c48
-rwxr-xr-xext/spl/spl_array.c185
-rwxr-xr-xext/spl/spl_directory.c107
-rw-r--r--ext/spl/spl_dllist.c6
-rw-r--r--ext/spl/spl_fixedarray.c4
-rw-r--r--ext/spl/spl_heap.c8
-rwxr-xr-xext/spl/spl_iterators.c60
-rwxr-xr-xext/spl/spl_observer.c19
-rwxr-xr-xext/spl/spl_sxe.c196
-rwxr-xr-xext/spl/spl_sxe.h40
-rwxr-xr-xext/spl/tests/array_001.phpt8
-rw-r--r--ext/spl/tests/bug42259.phpt49
-rw-r--r--ext/spl/tests/heap_007.phpt9
-rw-r--r--ext/spl/tests/pqueue_003.phpt8
-rwxr-xr-xext/spl/tests/spl_autoload_012.phpt12
-rwxr-xr-xext/spl/tests/sxe_001.phpt63
-rwxr-xr-xext/spl/tests/sxe_002.phpt75
-rwxr-xr-xext/spl/tests/sxe_003.phpt77
-rwxr-xr-xext/spl/tests/sxe_004.phpt145
-rwxr-xr-xext/spl/tests/sxe_005.phpt44
23 files changed, 915 insertions, 256 deletions
diff --git a/ext/spl/config.m4 b/ext/spl/config.m4
index a0f0d1a06d..f4e9b5ba5b 100755
--- a/ext/spl/config.m4
+++ b/ext/spl/config.m4
@@ -22,6 +22,6 @@ int main(int argc, char **argv) {
CPPFLAGS=$old_CPPFLAGS
AC_DEFINE_UNQUOTED(HAVE_PACKED_OBJECT_VALUE, $ac_result, [Whether struct _zend_object_value is packed])
AC_DEFINE(HAVE_SPL, 1, [Whether you want SPL (Standard PHP Library) support])
- PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no)
- PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_dllist.h spl_heap.h spl_fixedarray.h])
+ PHP_NEW_EXTENSION(spl, php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_sxe.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c, no)
+ PHP_INSTALL_HEADERS([ext/spl], [php_spl.h spl_array.h spl_directory.h spl_engine.h spl_exceptions.h spl_functions.h spl_iterators.h spl_observer.h spl_sxe.h spl_dllist.h spl_heap.h spl_fixedarray.h])
PHP_ADD_EXTENSION_DEP(spl, pcre, true)
diff --git a/ext/spl/config.w32 b/ext/spl/config.w32
index e594b0eb48..eeaec58bf6 100644
--- a/ext/spl/config.w32
+++ b/ext/spl/config.w32
@@ -1,6 +1,6 @@
// $Id$
// vim:ft=javascript
-EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */);
+EXTENSION("spl", "php_spl.c spl_functions.c spl_engine.c spl_iterators.c spl_array.c spl_directory.c spl_sxe.c spl_exceptions.c spl_observer.c spl_dllist.c spl_heap.c spl_fixedarray.c", false /*never shared */);
AC_DEFINE('HAVE_SPL', 1);
PHP_SPL="yes";
diff --git a/ext/spl/package.xml b/ext/spl/package.xml
index 372aaecd9f..f99cd7ce41 100755
--- a/ext/spl/package.xml
+++ b/ext/spl/package.xml
@@ -34,6 +34,8 @@ standard problems.
<file role="src" name="spl_functions.h"/>
<file role="src" name="spl_iterators.c"/>
<file role="src" name="spl_iterators.h"/>
+ <file role="src" name="spl_sxe.c"/>
+ <file role="src" name="spl_sxe.h"/>
<file role="doc" name="CREDITS"/>
<file role="doc" name="README"/>
<file role="doc" name="TODO"/>
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index 40b3b7eacd..22a264bde7 100755
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -32,6 +32,7 @@
#include "spl_array.h"
#include "spl_directory.h"
#include "spl_iterators.h"
+#include "spl_sxe.h"
#include "spl_exceptions.h"
#include "spl_observer.h"
#include "spl_dllist.h"
@@ -85,7 +86,7 @@ static zend_class_entry * spl_find_ce_by_name(char *name, int len, zend_bool aut
return *ce;
}
-/* {{{ proto array class_parents(object instance [, boolean autoload = true])
+/* {{{ proto array class_parents(object instance)
Return an array containing the names of all parent classes */
PHP_FUNCTION(class_parents)
{
@@ -190,6 +191,7 @@ PHP_FUNCTION(class_implements)
SPL_ADD_CLASS(RegexIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(RuntimeException, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(SeekableIterator, z_list, sub, allow, ce_flags); \
+ SPL_ADD_CLASS(SimpleXMLIterator, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(SplDoublyLinkedList, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(SplFileInfo, z_list, sub, allow, ce_flags); \
SPL_ADD_CLASS(SplFileObject, z_list, sub, allow, ce_flags); \
@@ -424,7 +426,7 @@ PHP_FUNCTION(spl_autoload_register)
zend_bool prepend = 0;
zend_function *spl_func_ptr;
autoload_func_info alfi;
- zval *obj_ptr;
+ zval **obj_ptr;
zend_fcall_info_cache fcc;
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS() TSRMLS_CC, "|zbb", &zcallable, &do_throw, &prepend) == FAILURE) {
@@ -446,7 +448,7 @@ PHP_FUNCTION(spl_autoload_register)
if (!zend_is_callable_ex(zcallable, NULL, IS_CALLABLE_STRICT, &func_name, &func_name_len, &fcc, &error TSRMLS_CC)) {
alfi.ce = fcc.calling_scope;
alfi.func_ptr = fcc.function_handler;
- obj_ptr = fcc.object_ptr;
+ obj_ptr = fcc.object_pp;
if (Z_TYPE_P(zcallable) == IS_ARRAY) {
if (!obj_ptr && alfi.func_ptr && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) {
if (do_throw) {
@@ -488,7 +490,7 @@ PHP_FUNCTION(spl_autoload_register)
}
alfi.ce = fcc.calling_scope;
alfi.func_ptr = fcc.function_handler;
- obj_ptr = fcc.object_ptr;
+ obj_ptr = fcc.object_pp;
if (error) {
efree(error);
}
@@ -503,10 +505,10 @@ PHP_FUNCTION(spl_autoload_register)
if (obj_ptr && !(alfi.func_ptr->common.fn_flags & ZEND_ACC_STATIC)) {
/* add object id to the hash to ensure uniqueness, for more reference look at bug #40091 */
- memcpy(lc_name + func_name_len, &Z_OBJ_HANDLE_P(obj_ptr), sizeof(zend_object_handle));
+ memcpy(lc_name + func_name_len, &Z_OBJ_HANDLE_PP(obj_ptr), sizeof(zend_object_handle));
func_name_len += sizeof(zend_object_handle);
lc_name[func_name_len] = '\0';
- alfi.obj = obj_ptr;
+ alfi.obj = *obj_ptr;
Z_ADDREF_P(alfi.obj);
} else {
alfi.obj = NULL;
@@ -558,7 +560,7 @@ PHP_FUNCTION(spl_autoload_unregister)
zval *zcallable;
int success = FAILURE;
zend_function *spl_func_ptr;
- zval *obj_ptr;
+ zval **obj_ptr;
zend_fcall_info_cache fcc;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &zcallable) == FAILURE) {
@@ -575,7 +577,7 @@ PHP_FUNCTION(spl_autoload_unregister)
}
RETURN_FALSE;
}
- obj_ptr = fcc.object_ptr;
+ obj_ptr = fcc.object_pp;
if (error) {
efree(error);
}
@@ -595,7 +597,7 @@ PHP_FUNCTION(spl_autoload_unregister)
success = zend_hash_del(SPL_G(autoload_functions), func_name, func_name_len+1);
if (success != SUCCESS && obj_ptr) {
func_name = erealloc(func_name, func_name_len + 1 + sizeof(zend_object_handle));
- memcpy(func_name + func_name_len, &Z_OBJ_HANDLE_P(obj_ptr), sizeof(zend_object_handle));
+ memcpy(func_name + func_name_len, &Z_OBJ_HANDLE_PP(obj_ptr), sizeof(zend_object_handle));
func_name_len += sizeof(zend_object_handle);
func_name[func_name_len] = '\0';
success = zend_hash_del(SPL_G(autoload_functions), func_name, func_name_len+1);
@@ -743,58 +745,70 @@ PHP_MINFO_FUNCTION(spl)
/* }}} */
/* {{{ arginfo */
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_iterator_to_array, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
ZEND_ARG_INFO(0, use_keys)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO(arginfo_iterator, 0)
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_iterator_apply, 0, 0, 2)
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
ZEND_ARG_INFO(0, function)
ZEND_ARG_ARRAY_INFO(0, args, 1)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_parents, 0, 0, 1)
ZEND_ARG_INFO(0, instance)
- ZEND_ARG_INFO(0, autoload)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_class_implements, 0, 0, 1)
ZEND_ARG_INFO(0, what)
ZEND_ARG_INFO(0, autoload)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_spl_classes, 0)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_spl_autoload_functions, 0)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_autoload, 0, 0, 1)
ZEND_ARG_INFO(0, class_name)
ZEND_ARG_INFO(0, file_extensions)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_autoload_extensions, 0, 0, 0)
ZEND_ARG_INFO(0, file_extensions)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_autoload_call, 0, 0, 1)
ZEND_ARG_INFO(0, class_name)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_autoload_register, 0, 0, 0)
ZEND_ARG_INFO(0, autoload_function)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_autoload_unregister, 0, 0, 1)
ZEND_ARG_INFO(0, autoload_function)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_spl_object_hash, 0, 0, 1)
ZEND_ARG_INFO(0, obj)
ZEND_END_ARG_INFO()
@@ -830,6 +844,7 @@ PHP_MINIT_FUNCTION(spl)
PHP_MINIT(spl_iterators)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(spl_array)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(spl_directory)(INIT_FUNC_ARGS_PASSTHRU);
+ PHP_MINIT(spl_sxe)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(spl_dllist)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(spl_heap)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(spl_fixedarray)(INIT_FUNC_ARGS_PASSTHRU);
@@ -862,10 +877,23 @@ PHP_RSHUTDOWN_FUNCTION(spl) /* {{{ */
return SUCCESS;
} /* }}} */
+#ifdef HAVE_SIMPLEXML
+static const zend_module_dep spl_deps[] = {
+ ZEND_MOD_REQUIRED("libxml")
+ ZEND_MOD_REQUIRED("simplexml")
+ {NULL, NULL, NULL}
+};
+#endif
+
/* {{{ spl_module_entry
*/
zend_module_entry spl_module_entry = {
+#ifdef HAVE_SIMPLEXML
+ STANDARD_MODULE_HEADER_EX, NULL,
+ spl_deps,
+#else
STANDARD_MODULE_HEADER,
+#endif
"SPL",
spl_functions,
PHP_MINIT(spl),
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index fb4d12a7de..14a6553258 100755
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -63,7 +63,6 @@ typedef struct _spl_array_object {
zval *array;
zval *retval;
HashPosition pos;
- ulong pos_h;
int ar_flags;
int is_self;
zend_function *fptr_offset_get;
@@ -93,44 +92,24 @@ static inline HashTable *spl_array_get_hash_table(spl_array_object* intern, int
static void spl_array_rewind(spl_array_object *intern TSRMLS_DC);
-static void spl_array_update_pos(spl_array_object* intern) /* {{{ */
-{
- Bucket *pos = intern->pos;
- if (pos != NULL) {
- intern->pos_h = pos->h;
- }
-} /* }}} */
-
-static void spl_array_set_pos(spl_array_object* intern, HashPosition pos) /* {{{ */
-{
- intern->pos = pos;
- spl_array_update_pos(intern);
-} /* }}} */
-
-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) /* {{{ */
{
+ HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
Bucket *p;
/* IS_CONSISTENT(ht);*/
/* HASH_PROTECT_RECURSION(ht);*/
- p = ht->arBuckets[intern->pos_h & ht->nTableMask];
+ p = ht->pListHead;
while (p != NULL) {
if (p == intern->pos) {
return SUCCESS;
}
- p = p->pNext;
+ p = p->pListNext;
}
/* HASH_UNPROTECT_RECURSION(ht); */
spl_array_rewind(intern TSRMLS_CC);
return FAILURE;
-
-} /* }}} */
-
-SPL_API int spl_hash_verify_pos(spl_array_object * intern TSRMLS_DC) /* {{{ */
-{
- HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
- return spl_hash_verify_pos_ex(intern, ht TSRMLS_CC);
}
/* }}} */
@@ -302,7 +281,6 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object,
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) {
@@ -315,17 +293,9 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object,
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);
- }
+ if (zend_symtable_find(spl_array_get_hash_table(intern, 0 TSRMLS_CC), Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &retval) == FAILURE) {
+ zend_error(E_NOTICE, "Undefined index: %s", Z_STRVAL_P(offset));
+ return &EG(uninitialized_zval_ptr);
} else {
return retval;
}
@@ -338,17 +308,9 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object,
} 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", Z_LVAL_P(offset));
- return &EG(uninitialized_zval_ptr);
- }
+ if (zend_hash_index_find(spl_array_get_hash_table(intern, 0 TSRMLS_CC), index, (void **) &retval) == FAILURE) {
+ zend_error(E_NOTICE, "Undefined offset: %ld", Z_LVAL_P(offset));
+ return &EG(uninitialized_zval_ptr);
} else {
return retval;
}
@@ -630,7 +592,7 @@ void spl_array_iterator_append(zval *object, zval *append_value TSRMLS_DC) /* {{
spl_array_write_dimension(object, NULL, append_value TSRMLS_CC);
if (!intern->pos) {
- spl_array_set_pos(intern, aht->pListTail);
+ intern->pos = aht->pListTail;
}
} /* }}} */
@@ -770,11 +732,12 @@ static void spl_array_unset_property(zval *object, zval *member TSRMLS_DC) /* {{
std_object_handlers.unset_property(object, member TSRMLS_CC);
} /* }}} */
-static int spl_array_skip_protected(spl_array_object *intern, HashTable *aht TSRMLS_DC) /* {{{ */
+static int spl_array_skip_protected(spl_array_object *intern TSRMLS_DC) /* {{{ */
{
char *string_key;
uint string_length;
ulong num_key;
+ HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
if (Z_TYPE_P(intern->array) == IS_OBJECT) {
do {
@@ -789,39 +752,27 @@ static int spl_array_skip_protected(spl_array_object *intern, HashTable *aht TSR
return FAILURE;
}
zend_hash_move_forward_ex(aht, &intern->pos);
- spl_array_update_pos(intern);
} while (1);
}
return FAILURE;
-} /* }}} */
+}
+/* }}} */
-static int spl_array_next_no_verify(spl_array_object *intern, HashTable *aht TSRMLS_DC) /* {{{ */
+static int spl_array_next(spl_array_object *intern TSRMLS_DC) /* {{{ */
{
- 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);
- }
-} /* }}} */
+ HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
-static int spl_array_next_ex(spl_array_object *intern, HashTable *aht TSRMLS_DC) /* {{{ */
-{
- if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
+ if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(intern 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;
+ } else {
+ zend_hash_move_forward_ex(aht, &intern->pos);
+ if (Z_TYPE_P(intern->array) == IS_OBJECT) {
+ return spl_array_skip_protected(intern TSRMLS_CC);
+ } else {
+ return zend_hash_has_more_elements_ex(aht, &intern->pos);
+ }
}
-
- return spl_array_next_no_verify(intern, aht TSRMLS_CC);
-} /* }}} */
-
-static int spl_array_next(spl_array_object *intern TSRMLS_DC) /* {{{ */
-{
- HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
-
- return spl_array_next_ex(intern, aht TSRMLS_CC);
-
} /* }}} */
/* define an overloaded iterator structure */
@@ -855,7 +806,7 @@ static int spl_array_it_valid(zend_object_iterator *iter TSRMLS_DC) /* {{{ */
return FAILURE;
}
- if (object->pos && (object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(object, aht TSRMLS_CC) == FAILURE) {
+ if (object->pos && (object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(object 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 {
@@ -895,7 +846,7 @@ static int spl_array_it_get_current_key(zend_object_iterator *iter, char **str_k
return HASH_KEY_NON_EXISTANT;
}
- if ((object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(object, aht TSRMLS_CC) == FAILURE) {
+ if ((object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(object 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;
}
@@ -920,24 +871,15 @@ static void spl_array_it_move_forward(zend_object_iterator *iter TSRMLS_DC) /* {
return;
}
- if ((object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(object, aht TSRMLS_CC) == FAILURE) {
+ if ((object->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(object 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);
+ spl_array_next(object TSRMLS_CC);
}
}
}
/* }}} */
-static void spl_array_rewind_ex(spl_array_object *intern, HashTable *aht TSRMLS_DC) /* {{{ */
-{
-
- zend_hash_internal_pointer_reset_ex(aht, &intern->pos);
- spl_array_update_pos(intern);
- spl_array_skip_protected(intern, aht TSRMLS_CC);
-
-} /* }}} */
-
static void spl_array_rewind(spl_array_object *intern TSRMLS_DC) /* {{{ */
{
HashTable *aht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
@@ -947,7 +889,8 @@ static void spl_array_rewind(spl_array_object *intern TSRMLS_DC) /* {{{ */
return;
}
- spl_array_rewind_ex(intern, aht TSRMLS_CC);
+ zend_hash_internal_pointer_reset_ex(aht, &intern->pos);
+ spl_array_skip_protected(intern TSRMLS_CC);
}
/* }}} */
@@ -1049,32 +992,34 @@ SPL_METHOD(Array, __construct)
spl_array_object *intern;
zval **array;
long ar_flags = 0;
- zend_class_entry *ce_get_iterator = spl_ce_Iterator;
- zend_error_handling error_handling;
+ char *class_name;
+ int class_name_len;
+ zend_class_entry ** pce_get_iterator;
if (ZEND_NUM_ARGS() == 0) {
return; /* nothing to do */
}
- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, NULL 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);
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z|ls", &array, &ar_flags, &class_name, &class_name_len) == FAILURE) {
return;
}
if (ZEND_NUM_ARGS() > 2) {
- intern->ce_get_iterator = ce_get_iterator;
+ if (zend_lookup_class(class_name, class_name_len, &pce_get_iterator TSRMLS_CC) == FAILURE) {
+ zend_throw_exception(spl_ce_InvalidArgumentException, "A class that implements Iterator must be specified", 0 TSRMLS_CC);
+ return;
+ }
+ intern->ce_get_iterator = *pce_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);
-
}
/* }}} */
@@ -1084,13 +1029,19 @@ SPL_METHOD(Array, setIteratorClass)
{
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;
+ char *class_name;
+ int class_name_len;
+ zend_class_entry ** pce_get_iterator;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "C", &ce_get_iterator) == FAILURE) {
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &class_name, &class_name_len) == FAILURE) {
return;
}
- intern->ce_get_iterator = ce_get_iterator;
+ if (zend_lookup_class(class_name, class_name_len, &pce_get_iterator TSRMLS_CC) == FAILURE) {
+ zend_throw_exception(spl_ce_InvalidArgumentException, "A class that implements Iterator must be specified", 0 TSRMLS_CC);
+ return;
+ }
+ intern->ce_get_iterator = *pce_get_iterator;
}
/* }}} */
@@ -1237,7 +1188,7 @@ int static spl_array_object_count_elements_helper(spl_array_object *intern, long
while(intern->pos && spl_array_next(intern TSRMLS_CC) == SUCCESS) {
(*count)++;
}
- spl_array_set_pos(intern, pos);
+ intern->pos = pos;
return SUCCESS;
} else {
*count = zend_hash_num_elements(aht);
@@ -1284,7 +1235,6 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam
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;
@@ -1292,20 +1242,15 @@ static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fnam
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;
}
- zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 2, tmp, arg TSRMLS_CC);
+ zend_call_method(NULL, NULL, NULL, fname, fname_len, return_value_ptr, 2, tmp, arg TSRMLS_CC);
} else {
- zend_call_method(NULL, NULL, NULL, fname, fname_len, &retval_ptr, 1, tmp, NULL TSRMLS_CC);
+ zend_call_method(NULL, NULL, NULL, fname, fname_len, return_value_ptr, 1, tmp, NULL TSRMLS_CC);
}
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);
- }
} /* }}} */
#define SPL_ARRAY_METHOD(cname, fname, use_arg) \
@@ -1358,7 +1303,7 @@ SPL_METHOD(Array, current)
return;
}
- if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
+ if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(intern TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid");
return;
}
@@ -1390,7 +1335,7 @@ void spl_array_iterator_key(zval *object, zval *return_value TSRMLS_DC) /* {{{ *
return;
}
- if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
+ if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(intern TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid");
return;
}
@@ -1421,7 +1366,7 @@ SPL_METHOD(Array, next)
return;
}
- spl_array_next_ex(intern, aht TSRMLS_CC);
+ spl_array_next(intern TSRMLS_CC);
}
/* }}} */
@@ -1438,7 +1383,7 @@ SPL_METHOD(Array, valid)
return;
}
- if (intern->pos && (intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
+ if (intern->pos && (intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(intern 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 {
@@ -1460,7 +1405,7 @@ SPL_METHOD(Array, hasChildren)
RETURN_FALSE;
}
- if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
+ if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(intern 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;
}
@@ -1486,7 +1431,7 @@ SPL_METHOD(Array, getChildren)
return;
}
- if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos_ex(intern, aht TSRMLS_CC) == FAILURE) {
+ if ((intern->ar_flags & SPL_ARRAY_IS_REF) && spl_hash_verify_pos(intern TSRMLS_CC) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_NOTICE, "Array was modified outside object and internal position is no longer valid");
return;
}
@@ -1644,7 +1589,7 @@ void spl_array_unserialize_helper(spl_array_object *intern, const unsigned char
++p;
if (*p!='m') {
- if (*p!='a' && *p!='O' && *p!='C') {
+ if (*p!='a') {
goto outexcept;
}
intern->ar_flags &= ~SPL_ARRAY_CLONE_MASK;
@@ -1752,43 +1697,53 @@ int spl_array_unserialize(zval **object, zend_class_entry *ce, const unsigned ch
/* }}} */
/* {{{ arginfo and function tbale */
+static
ZEND_BEGIN_ARG_INFO(arginfo_array___construct, 0)
ZEND_ARG_INFO(0, array)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_offsetGet, 0, 0, 1)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_offsetSet, 0, 0, 2)
ZEND_ARG_INFO(0, index)
ZEND_ARG_INFO(0, newval)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_array_append, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_array_seek, 0)
ZEND_ARG_INFO(0, position)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_array_exchangeArray, 0)
ZEND_ARG_INFO(0, array)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_array_setFlags, 0)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_array_setIteratorClass, 0)
ZEND_ARG_INFO(0, iteratorClass)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_array_uXsort, 0)
ZEND_ARG_INFO(0, cmp_function)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO(arginfo_array_unserialize, 0)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO();
diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c
index 44921de279..84aad7f7b3 100755
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -221,7 +221,7 @@ static void spl_filesystem_dir_open(spl_filesystem_object* intern, char *path TS
intern->_path_len = strlen(path);
intern->u.dir.dirp = php_stream_opendir(path, ENFORCE_SAFE_MODE|REPORT_ERRORS, NULL);
- if (intern->_path_len > 1 && IS_SLASH_AT(path, intern->_path_len-1)) {
+ if (intern->_path_len && IS_SLASH_AT(path, intern->_path_len-1)) {
intern->_path = estrndup(path, --intern->_path_len);
} else {
intern->_path = estrndup(path, intern->_path_len);
@@ -258,7 +258,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu
zend_list_addref(Z_RESVAL_P(intern->u.file.zcontext));
}
- if (intern->file_name_len > 1 && IS_SLASH_AT(intern->file_name, intern->file_name_len-1)) {
+ if (intern->file_name_len && IS_SLASH_AT(intern->file_name, intern->file_name_len-1)) {
intern->file_name_len--;
}
@@ -349,7 +349,7 @@ void spl_filesystem_info_set_filename(spl_filesystem_object *intern, char *path,
intern->file_name = use_copy ? estrndup(path, len) : path;
intern->file_name_len = len;
- while(IS_SLASH_AT(intern->file_name, intern->file_name_len-1) && intern->file_name_len > 1) {
+ while(IS_SLASH_AT(intern->file_name, intern->file_name_len-1)) {
intern->file_name[intern->file_name_len-1] = 0;
intern->file_name_len--;
}
@@ -373,7 +373,6 @@ static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_
{
spl_filesystem_object *intern;
zval *arg1;
- zend_error_handling error_handling;
if (!file_path || !file_path_len) {
#if defined(PHP_WIN32)
@@ -392,7 +391,7 @@ static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_
return NULL;
}
- zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
ce = ce ? ce : source->info_class;
return_value->value.obj = spl_filesystem_object_new_ex(ce, &intern TSRMLS_CC);
@@ -407,7 +406,6 @@ static spl_filesystem_object * spl_filesystem_object_create_info(spl_filesystem_
spl_filesystem_info_set_filename(intern, file_path, file_path_len, use_copy TSRMLS_CC);
}
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return intern;
} /* }}} */
@@ -480,7 +478,6 @@ static spl_filesystem_object * spl_filesystem_object_create_type(int ht, spl_fil
&use_include_path, &intern->u.file.zcontext) == FAILURE) {
zend_restore_error_handling(&error_handling TSRMLS_CC);
intern->u.file.open_mode = NULL;
- intern->file_name = NULL;
zval_dtor(return_value);
Z_TYPE_P(return_value) = IS_NULL;
return NULL;
@@ -606,9 +603,8 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, int ctor_flag
char *path;
int parsed, len;
long flags;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
if (ctor_flags & DIT_CTOR_FLAGS) {
flags = SPL_FILE_DIR_KEY_AS_PATHNAME|SPL_FILE_DIR_CURRENT_AS_FILEINFO;
@@ -624,12 +620,10 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, int ctor_flag
flags |= SPL_FILE_DIR_UNIXPATHS;
}
if (parsed == FAILURE) {
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
if (!len) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0 TSRMLS_CC, "Directory name must not be empty.");
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
@@ -645,7 +639,6 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, int ctor_flag
intern->u.dir.is_recursive = instanceof_function(intern->std.ce, spl_ce_RecursiveDirectoryIterator TSRMLS_CC) ? 1 : 0;
- zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
@@ -920,20 +913,16 @@ SPL_METHOD(SplFileInfo, __construct)
spl_filesystem_object *intern;
char *path;
int len;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &path, &len) == FAILURE) {
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
spl_filesystem_info_set_filename(intern, path, len, 1 TSRMLS_CC);
-
- zend_restore_error_handling(&error_handling TSRMLS_CC);
/* intern->type = SPL_FS_INFO; already set */
}
@@ -944,12 +933,10 @@ SPL_METHOD(SplFileInfo, __construct)
SPL_METHOD(SplFileInfo, func_name) \
{ \
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC); \
- zend_error_handling error_handling; \
\
- zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);\
+ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);\
spl_filesystem_object_get_file_name(intern TSRMLS_CC); \
php_stat(intern->file_name, intern->file_name_len, func_num, return_value TSRMLS_CC); \
- zend_restore_error_handling(&error_handling TSRMLS_CC); \
}
/* }}} */
@@ -1035,9 +1022,8 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
int ret;
char buff[MAXPATHLEN];
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
#ifdef HAVE_SYMLINK
ret = readlink(intern->file_name, buff, MAXPATHLEN-1);
@@ -1054,8 +1040,6 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
RETVAL_STRINGL(buff, ret, 1);
}
-
- zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
@@ -1067,9 +1051,8 @@ SPL_METHOD(SplFileInfo, getRealPath)
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
char buff[MAXPATHLEN];
char *filename;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
if (intern->type == SPL_FS_DIR && !intern->file_name && intern->u.dir.entry.d_name[0]) {
spl_filesystem_object_get_file_name(intern TSRMLS_CC);
@@ -1092,8 +1075,6 @@ SPL_METHOD(SplFileInfo, getRealPath)
} else {
RETVAL_FALSE;
}
-
- zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
#endif
@@ -1114,15 +1095,12 @@ SPL_METHOD(SplFileInfo, setFileClass)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zend_class_entry *ce = spl_ce_SplFileObject;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
intern->file_class = ce;
}
-
- zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
@@ -1132,15 +1110,12 @@ SPL_METHOD(SplFileInfo, setInfoClass)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zend_class_entry *ce = spl_ce_SplFileInfo;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
intern->info_class = ce;
}
-
- zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
@@ -1150,15 +1125,12 @@ SPL_METHOD(SplFileInfo, getFileInfo)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zend_class_entry *ce = intern->info_class;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
spl_filesystem_object_create_type(ht, intern, SPL_FS_INFO, ce, return_value TSRMLS_CC);
}
-
- zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
@@ -1168,9 +1140,8 @@ SPL_METHOD(SplFileInfo, getPathInfo)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
zend_class_entry *ce = intern->info_class;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, NULL TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|C", &ce) == SUCCESS) {
int path_len;
@@ -1179,8 +1150,6 @@ SPL_METHOD(SplFileInfo, getPathInfo)
spl_filesystem_object_create_info(intern, path, path_len, 1, ce, return_value TSRMLS_CC);
}
}
-
- zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
@@ -1613,20 +1582,24 @@ static int spl_filesystem_object_cast(zval *readobj, zval *writeobj, int type TS
/* {{{ declare method parameters */
/* supply a name and default to call by parameter */
+static
ZEND_BEGIN_ARG_INFO(arginfo_info___construct, 0)
ZEND_ARG_INFO(0, file_name)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_info_openFile, 0, 0, 0)
ZEND_ARG_INFO(0, open_mode)
ZEND_ARG_INFO(0, use_include_path)
ZEND_ARG_INFO(0, context)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_info_optinalFileClass, 0, 0, 0)
ZEND_ARG_INFO(0, class_name)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_optinalSuffix, 0, 0, 0)
ZEND_ARG_INFO(0, suffix)
ZEND_END_ARG_INFO()
@@ -1667,10 +1640,12 @@ static const zend_function_entry spl_SplFileInfo_functions[] = {
{NULL, NULL, NULL}
};
+static
ZEND_BEGIN_ARG_INFO(arginfo_dir___construct, 0)
ZEND_ARG_INFO(0, path)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_dir_it_seek, 0)
ZEND_ARG_INFO(0, position)
ZEND_END_ARG_INFO();
@@ -1692,15 +1667,18 @@ static const zend_function_entry spl_DirectoryIterator_functions[] = {
{NULL, NULL, NULL}
};
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_r_dir___construct, 0, 0, 1)
ZEND_ARG_INFO(0, path)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_r_dir_hasChildren, 0, 0, 0)
ZEND_ARG_INFO(0, allow_links)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_r_dir_setFlags, 0, 0, 0)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
@@ -1805,7 +1783,7 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
fci.size = sizeof(fci);
fci.function_table = EG(function_table);
- fci.object_ptr = NULL;
+ fci.object_pp = NULL;
fci.function_name = &z_fname;
fci.retval_ptr_ptr = &retval;
fci.param_count = num_args;
@@ -1817,7 +1795,7 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
fcic.function_handler = func_ptr;
fcic.calling_scope = NULL;
fcic.called_scope = NULL;
- fcic.object_ptr = NULL;
+ fcic.object_pp = NULL;
result = zend_call_function(&fci, &fcic TSRMLS_CC);
@@ -1970,9 +1948,8 @@ SPL_METHOD(SplFileObject, __construct)
char *p1, *p2;
char *tmp_path;
int tmp_path_len;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
intern->u.file.open_mode = "r";
intern->u.file.open_mode_len = 1;
@@ -1981,14 +1958,13 @@ SPL_METHOD(SplFileObject, __construct)
&intern->file_name, &intern->file_name_len,
&intern->u.file.open_mode, &intern->u.file.open_mode_len,
&use_include_path, &intern->u.file.zcontext) == FAILURE) {
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
if (spl_filesystem_file_open(intern, use_include_path, 0 TSRMLS_CC) == SUCCESS) {
tmp_path_len = strlen(intern->u.file.stream->orig_path);
- if (tmp_path_len > 1 && IS_SLASH_AT(intern->u.file.stream->orig_path, tmp_path_len-1)) {
+ if (tmp_path_len && IS_SLASH_AT(intern->u.file.stream->orig_path, tmp_path_len-1)) {
tmp_path_len--;
}
@@ -2011,8 +1987,6 @@ SPL_METHOD(SplFileObject, __construct)
intern->_path = estrndup(intern->u.file.stream->orig_path, intern->_path_len);
}
- zend_restore_error_handling(&error_handling TSRMLS_CC);
-
} /* }}} */
/* {{{ proto void SplTempFileObject::__construct([int max_memory])
@@ -2022,12 +1996,10 @@ SPL_METHOD(SplTempFileObject, __construct)
long max_memory = PHP_STREAM_MAX_MEM;
char tmp_fname[48];
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, NULL TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &max_memory) == FAILURE) {
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
@@ -2049,7 +2021,6 @@ SPL_METHOD(SplTempFileObject, __construct)
intern->_path_len = 0;
intern->_path = estrndup("", 0);
}
- zend_restore_error_handling(&error_handling TSRMLS_CC);
} /* }}} */
/* {{{ proto void SplFileObject::rewind()
@@ -2214,8 +2185,8 @@ SPL_METHOD(SplFileObject, fgetcsv)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
char delimiter = intern->u.file.delimiter, enclosure = intern->u.file.enclosure, escape = intern->u.file.escape;
- char *delim = NULL, *enclo = NULL, *esc = NULL;
- int d_len = 0, e_len = 0, esc_len = 0;
+ char *delim, *enclo, *esc;
+ int d_len, e_len, esc_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sss", &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) {
switch(ZEND_NUM_ARGS())
@@ -2255,8 +2226,8 @@ SPL_METHOD(SplFileObject, setCsvControl)
{
spl_filesystem_object *intern = (spl_filesystem_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
char delimiter = ',', enclosure = '"', escape='\\';
- char *delim = NULL, *enclo = NULL, *esc = NULL;
- int d_len = 0, e_len = 0, esc_len = 0;
+ char *delim, *enclo, *esc;
+ int d_len, e_len, esc_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sss", &delim, &d_len, &enclo, &e_len, &esc, &esc_len) == SUCCESS) {
switch(ZEND_NUM_ARGS())
@@ -2497,13 +2468,12 @@ SPL_METHOD(SplFileObject, seek)
spl_filesystem_file_rewind(getThis(), intern TSRMLS_CC);
while(intern->u.file.current_line_num < line_pos) {
- if (spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC) == FAILURE) {
- break;
- }
+ spl_filesystem_file_read_line(getThis(), intern, 1 TSRMLS_CC);
}
} /* }}} */
/* {{{ Function/Class/Method definitions */
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object___construct, 0, 0, 1)
ZEND_ARG_INFO(0, file_name)
ZEND_ARG_INFO(0, open_mode)
@@ -2511,46 +2481,56 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object___construct, 0, 0, 1)
ZEND_ARG_INFO(0, context)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_file_object_setFlags, 0)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_file_object_setMaxLineLen, 0)
ZEND_ARG_INFO(0, max_len)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fgetcsv, 0, 0, 0)
ZEND_ARG_INFO(0, delimiter)
ZEND_ARG_INFO(0, enclosure)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_flock, 0, 0, 1)
ZEND_ARG_INFO(0, operation)
ZEND_ARG_INFO(1, wouldblock)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fseek, 0, 0, 1)
ZEND_ARG_INFO(0, pos)
ZEND_ARG_INFO(0, whence)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fgetss, 0, 0, 0)
ZEND_ARG_INFO(0, allowable_tags)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fscanf, 0, 0, 1)
ZEND_ARG_INFO(0, format)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_fwrite, 0, 0, 1)
ZEND_ARG_INFO(0, str)
ZEND_ARG_INFO(0, length)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_ftruncate, 0, 0, 1)
ZEND_ARG_INFO(0, size)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_file_object_seek, 0, 0, 1)
ZEND_ARG_INFO(0, line_pos)
ZEND_END_ARG_INFO()
@@ -2591,6 +2571,7 @@ static const zend_function_entry spl_SplFileObject_functions[] = {
{NULL, NULL, NULL}
};
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_temp_file_object___construct, 0, 0, 0)
ZEND_ARG_INFO(0, max_memory)
ZEND_END_ARG_INFO()
diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c
index 7814c3e1f6..536a02532c 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -818,7 +818,6 @@ SPL_METHOD(SplDoublyLinkedList, offsetSet)
index = spl_offset_convert_to_long(zindex TSRMLS_CC);
if (index < 0 || index >= intern->llist->count) {
- zval_ptr_dtor(&value);
zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid or out of range", 0 TSRMLS_CC);
return;
}
@@ -841,7 +840,6 @@ SPL_METHOD(SplDoublyLinkedList, offsetSet)
intern->llist->ctor(element TSRMLS_CC);
}
} else {
- zval_ptr_dtor(&value);
zend_throw_exception(spl_ce_OutOfRangeException, "Offset invalid", 0 TSRMLS_CC);
return;
}
@@ -1122,18 +1120,22 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object
/* }}} */
/* Function/Class/Method definitions */
+static
ZEND_BEGIN_ARG_INFO(arginfo_dllist_setiteratormode, 0)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_dllist_push, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_dllist_offsetGet, 0, 0, 1)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_dllist_offsetSet, 0, 0, 2)
ZEND_ARG_INFO(0, index)
ZEND_ARG_INFO(0, newval)
diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index 1e56a14820..884cc1eff9 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -1002,19 +1002,23 @@ zend_object_iterator *spl_fixedarray_get_iterator(zend_class_entry *ce, zval *ob
}
/* }}} */
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_fixedarray_offsetGet, 0, 0, 1)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_fixedarray_offsetSet, 0, 0, 2)
ZEND_ARG_INFO(0, index)
ZEND_ARG_INFO(0, newval)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_fixedarray_setSize, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_fixedarray_fromArray, 0, 0, 1)
ZEND_ARG_INFO(0, data)
ZEND_ARG_INFO(0, save_indexes)
diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c
index f073597af1..3b210954f6 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -970,8 +970,8 @@ static void spl_heap_it_move_forward(zend_object_iterator *iter TSRMLS_DC) /* {{
SPL_METHOD(SplHeap, key)
{
spl_heap_object *intern = (spl_heap_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
-
- RETURN_LONG(intern->heap->count - 1);
+
+ RETURN_LONG(intern->heap->count);
}
/* }}} */
@@ -1110,20 +1110,24 @@ zend_object_iterator *spl_pqueue_get_iterator(zend_class_entry *ce, zval *object
}
/* }}} */
+static
ZEND_BEGIN_ARG_INFO(arginfo_heap_insert, 0)
ZEND_ARG_INFO(0, value)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_heap_compare, 0)
ZEND_ARG_INFO(0, a)
ZEND_ARG_INFO(0, b)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_pqueue_insert, 0)
ZEND_ARG_INFO(0, value)
ZEND_ARG_INFO(0, priority)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO(arginfo_pqueue_setflags, 0)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c
index 24aaad1e39..10426c3192 100755
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -424,9 +424,8 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
zend_class_entry *ce_iterator;
long mode, flags;
int inc_refcount = 1;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
switch(rit_type) {
case RIT_RecursiveTreeIterator: {
@@ -482,7 +481,6 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
zval_ptr_dtor(&iterator);
}
zend_throw_exception(spl_ce_InvalidArgumentException, "An instance of RecursiveIterator or IteratorAggregate creating it is required", 0 TSRMLS_CC);
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
@@ -532,7 +530,6 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
intern->iterators[0].ce = ce_iterator;
intern->iterators[0].state = RS_START;
- zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* {{{ proto void RecursiveIteratorIterator::__construct(RecursiveIterator|IteratorAggregate it [, int mode = RIT_LEAVES_ONLY [, int flags = 0]]) throws InvalidArgumentException
@@ -842,16 +839,19 @@ static zend_object_value spl_RecursiveTreeIterator_new(zend_class_entry *class_t
}
/* }}} */
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_recursive_it___construct, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
ZEND_ARG_INFO(0, mode)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_recursive_it_getSubIterator, 0, 0, 0)
ZEND_ARG_INFO(0, level)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_recursive_it_setMaxDepth, 0, 0, 0)
ZEND_ARG_INFO(0, max_depth)
ZEND_END_ARG_INFO();
@@ -1098,6 +1098,7 @@ SPL_METHOD(RecursiveTreeIterator, key)
RETVAL_STRINGL(str, str_len, 0);
} /* }}} */
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_recursive_tree_it___construct, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
ZEND_ARG_INFO(0, flags)
@@ -1105,6 +1106,7 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_recursive_tree_it___construct, 0, 0, 1)
ZEND_ARG_INFO(0, mode)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_recursive_tree_it_setPrefixPart, 0, 0, 2)
ZEND_ARG_INFO(0, part)
ZEND_ARG_INFO(0, value)
@@ -1240,7 +1242,6 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
spl_dual_it_object *intern;
zend_class_entry *ce = NULL;
int inc_refcount = 1;
- zend_error_handling error_handling;
intern = (spl_dual_it_object*)zend_object_store_get_object(getThis() TSRMLS_CC);
@@ -1249,7 +1250,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
return NULL;
}
- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
intern->dit_type = dit_type;
switch (dit_type) {
@@ -1257,17 +1258,14 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
intern->u.limit.offset = 0; /* start at beginning */
intern->u.limit.count = -1; /* get all */
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|ll", &zobject, ce_inner, &intern->u.limit.offset, &intern->u.limit.count) == FAILURE) {
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
if (intern->u.limit.offset < 0) {
zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be > 0", 0 TSRMLS_CC);
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
if (intern->u.limit.count < 0 && intern->u.limit.count != -1) {
zend_throw_exception(spl_ce_OutOfRangeException, "Parameter count must either be -1 or a value greater than or equal 0", 0 TSRMLS_CC);
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
break;
@@ -1276,12 +1274,10 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
case DIT_RecursiveCachingIterator: {
long flags = CIT_CALL_TOSTRING;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|l", &zobject, ce_inner, &flags) == FAILURE) {
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
if (spl_cit_check_flags(flags) != SUCCESS) {
zend_throw_exception(spl_ce_InvalidArgumentException, "Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_CURRENT", 0 TSRMLS_CC);
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
intern->u.caching.flags |= flags & CIT_PUBLIC;
@@ -1291,11 +1287,10 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
}
case DIT_IteratorIterator: {
zend_class_entry **pce_cast;
- char * class_name = NULL;
- int class_name_len = 0;
+ char * class_name;
+ int class_name_len;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O|s", &zobject, ce_inner, &class_name, &class_name_len) == FAILURE) {
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
ce = Z_OBJCE_P(zobject);
@@ -1306,7 +1301,6 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
|| !(*pce_cast)->get_iterator
) {
zend_throw_exception(spl_ce_LogicException, "Class to downcast to not found or not base class or does not implement Traversable", 0 TSRMLS_CC);
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
ce = *pce_cast;
@@ -1317,12 +1311,10 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
if (retval) {
zval_ptr_dtor(&retval);
}
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
if (!retval || Z_TYPE_P(retval) != IS_OBJECT || !instanceof_function(Z_OBJCE_P(retval), zend_ce_traversable TSRMLS_CC)) {
zend_throw_exception_ex(spl_ce_LogicException, 0 TSRMLS_CC, "%s::getIterator() must return an object that implememnts Traversable", ce->name);
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
zobject = retval;
@@ -1336,7 +1328,6 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
spl_instantiate(spl_ce_ArrayIterator, &intern->u.append.zarrayit, 1 TSRMLS_CC);
zend_call_method_with_0_params(&intern->u.append.zarrayit, spl_ce_ArrayIterator, &spl_ce_ArrayIterator->constructor, "__construct", NULL);
intern->u.append.iterator = spl_ce_ArrayIterator->get_iterator(spl_ce_ArrayIterator, intern->u.append.zarrayit, 0 TSRMLS_CC);
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return intern;
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
case DIT_RegexIterator:
@@ -1349,12 +1340,10 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
intern->u.regex.flags = 0;
intern->u.regex.preg_flags = 0;
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Os|lll", &zobject, ce_inner, &regex, &regex_len, &mode, &intern->u.regex.flags, &intern->u.regex.preg_flags) == FAILURE) {
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
if (mode < 0 || mode >= REGIT_MODE_MAX) {
zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0 TSRMLS_CC, "Illegal mode %ld", mode);
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
intern->u.regex.mode = mode;
@@ -1362,7 +1351,6 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
intern->u.regex.pce = pcre_get_compiled_regex_cache(regex, regex_len TSRMLS_CC);
if (intern->u.regex.pce == NULL) {
/* pcre_get_compiled_regex_cache has already sent error */
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
intern->u.regex.pce->refcount++;
@@ -1371,13 +1359,12 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
#endif
default:
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "O", &zobject, ce_inner) == FAILURE) {
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return NULL;
}
break;
}
- zend_restore_error_handling(&error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, NULL, NULL TSRMLS_CC);
if (inc_refcount) {
Z_ADDREF_P(zobject);
@@ -1458,9 +1445,6 @@ static inline void spl_dual_it_rewind(spl_dual_it_object *intern TSRMLS_DC)
static inline int spl_dual_it_valid(spl_dual_it_object *intern TSRMLS_DC)
{
- if (!intern->inner.iterator) {
- return FAILURE;
- }
/* FAILURE / SUCCESS */
return intern->inner.iterator->funcs->valid(intern->inner.iterator TSRMLS_CC);
}
@@ -1702,11 +1686,7 @@ SPL_METHOD(RegexIterator, accept)
char *subject, tmp[32], *result;
int subject_len, use_copy, count, result_len;
zval subject_copy, zcount, *replacement;
-
- if (intern->current.data == NULL) {
- RETURN_FALSE;
- }
-
+
if (intern->u.regex.flags & REGIT_USE_KEY) {
if (intern->current.key_type == HASH_KEY_IS_LONG) {
subject_len = slprintf(tmp, sizeof(tmp), "%ld", intern->current.int_key);
@@ -1964,6 +1944,7 @@ static zend_object_value spl_dual_it_new(zend_class_entry *class_type TSRMLS_DC)
}
/* }}} */
+static
ZEND_BEGIN_ARG_INFO(arginfo_filter_it___construct, 0)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_END_ARG_INFO();
@@ -1980,6 +1961,7 @@ static const zend_function_entry spl_funcs_FilterIterator[] = {
{NULL, NULL, NULL}
};
+static
ZEND_BEGIN_ARG_INFO(arginfo_parent_it___construct, 0)
ZEND_ARG_OBJ_INFO(0, iterator, RecursiveIterator, 0)
ZEND_END_ARG_INFO();
@@ -1998,6 +1980,7 @@ static const zend_function_entry spl_funcs_ParentIterator[] = {
};
#if HAVE_PCRE || HAVE_BUNDLED_PCRE
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_regex_it___construct, 0, 0, 2)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_ARG_INFO(0, regex)
@@ -2006,14 +1989,17 @@ ZEND_BEGIN_ARG_INFO_EX(arginfo_regex_it___construct, 0, 0, 2)
ZEND_ARG_INFO(0, preg_flags)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_regex_it_set_mode, 0, 0, 1)
ZEND_ARG_INFO(0, mode)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_regex_it_set_flags, 0, 0, 1)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_regex_it_set_preg_flags, 0, 0, 1)
ZEND_ARG_INFO(0, preg_flags)
ZEND_END_ARG_INFO();
@@ -2030,6 +2016,7 @@ static const zend_function_entry spl_funcs_RegexIterator[] = {
{NULL, NULL, NULL}
};
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_rec_regex_it___construct, 0, 0, 2)
ZEND_ARG_OBJ_INFO(0, iterator, RecursiveIterator, 0)
ZEND_ARG_INFO(0, regex)
@@ -2165,6 +2152,7 @@ SPL_METHOD(LimitIterator, getPosition)
RETURN_LONG(intern->current.pos);
} /* }}} */
+static
ZEND_BEGIN_ARG_INFO(arginfo_seekable_it_seek, 0)
ZEND_ARG_INFO(0, position)
ZEND_END_ARG_INFO();
@@ -2174,12 +2162,14 @@ static const zend_function_entry spl_funcs_SeekableIterator[] = {
{NULL, NULL, NULL}
};
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_limit_it___construct, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_ARG_INFO(0, offset)
ZEND_ARG_INFO(0, count)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO(arginfo_limit_it_seek, 0)
ZEND_ARG_INFO(0, position)
ZEND_END_ARG_INFO();
@@ -2558,19 +2548,23 @@ SPL_METHOD(CachingIterator, count)
}
/* }}} */
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_caching_it___construct, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO(arginfo_caching_it_setFlags, 0)
ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO(arginfo_caching_it_offsetGet, 0)
ZEND_ARG_INFO(0, index)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO(arginfo_caching_it_offsetSet, 0)
ZEND_ARG_INFO(0, index)
ZEND_ARG_INFO(0, newval)
@@ -2630,6 +2624,7 @@ SPL_METHOD(RecursiveCachingIterator, getChildren)
}
} /* }}} */
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_caching_rec_it___construct, 0, ZEND_RETURN_VALUE, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_ARG_INFO(0, flags)
@@ -2649,6 +2644,7 @@ SPL_METHOD(IteratorIterator, __construct)
spl_dual_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, spl_ce_IteratorIterator, zend_ce_traversable, DIT_IteratorIterator);
} /* }}} */
+static
ZEND_BEGIN_ARG_INFO(arginfo_iterator_it___construct, 0)
ZEND_ARG_OBJ_INFO(0, iterator, Traversable, 0)
ZEND_END_ARG_INFO();
@@ -2737,6 +2733,7 @@ SPL_METHOD(NoRewindIterator, next)
intern->inner.iterator->funcs->move_forward(intern->inner.iterator TSRMLS_CC);
} /* }}} */
+static
ZEND_BEGIN_ARG_INFO(arginfo_norewind_it___construct, 0)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_END_ARG_INFO();
@@ -2969,6 +2966,7 @@ SPL_METHOD(AppendIterator, getArrayIterator)
RETURN_ZVAL(intern->u.append.zarrayit, 1, 0);
} /* }}} */
+static
ZEND_BEGIN_ARG_INFO(arginfo_append_it_append, 0)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_END_ARG_INFO();
diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c
index e2f97889ed..85b5e193df 100755
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -43,6 +43,7 @@ SPL_METHOD(SplSubject, attach);
SPL_METHOD(SplSubject, detach);
SPL_METHOD(SplSubject, notify);
+static
ZEND_BEGIN_ARG_INFO(arginfo_SplObserver_update, 0)
ZEND_ARG_OBJ_INFO(0, SplSubject, SplSubject, 0)
ZEND_END_ARG_INFO();
@@ -52,11 +53,13 @@ static const zend_function_entry spl_funcs_SplObserver[] = {
{NULL, NULL, NULL}
};
+static
ZEND_BEGIN_ARG_INFO(arginfo_SplSubject_attach, 0)
ZEND_ARG_OBJ_INFO(0, SplObserver, SplObserver, 0)
ZEND_END_ARG_INFO();
-/*ZEND_BEGIN_ARG_INFO_EX(arginfo_SplSubject_notify, 0, 0, 1)
+/*static
+ZEND_BEGIN_ARG_INFO_EX(arginfo_SplSubject_notify, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, ignore, SplObserver, 1)
ZEND_END_ARG_INFO();*/
@@ -563,27 +566,33 @@ outexcept:
} /* }}} */
+static
ZEND_BEGIN_ARG_INFO(arginfo_Object, 0)
ZEND_ARG_INFO(0, object)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_attach, 0, 0, 1)
ZEND_ARG_INFO(0, object)
ZEND_ARG_INFO(0, inf)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO(arginfo_Serialized, 0)
ZEND_ARG_INFO(0, serialized)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO(arginfo_setInfo, 0)
ZEND_ARG_INFO(0, info)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetGet, 0, 0, 1)
ZEND_ARG_INFO(0, object)
ZEND_END_ARG_INFO()
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_offsetSet, 0, 0, 2)
ZEND_ARG_INFO(0, object)
ZEND_ARG_INFO(0, info)
@@ -630,18 +639,15 @@ SPL_METHOD(MultipleIterator, __construct)
{
spl_SplObjectStorage *intern;
long flags = MIT_NEED_ALL|MIT_KEYS_NUMERIC;
- zend_error_handling error_handling;
- zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, &error_handling TSRMLS_CC);
+ zend_replace_error_handling(EH_THROW, spl_ce_InvalidArgumentException, NULL TSRMLS_CC);
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|l", &flags) == FAILURE) {
- zend_restore_error_handling(&error_handling TSRMLS_CC);
return;
}
intern = (spl_SplObjectStorage*)zend_object_store_get_object(getThis() TSRMLS_CC);
intern->flags = flags;
- zend_restore_error_handling(&error_handling TSRMLS_CC);
}
/* }}} */
@@ -872,15 +878,18 @@ SPL_METHOD(MultipleIterator, key)
}
/* }}} */
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_MultipleIterator_attachIterator, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_ARG_INFO(0, infos)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_MultipleIterator_detachIterator, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_END_ARG_INFO();
+static
ZEND_BEGIN_ARG_INFO_EX(arginfo_MultipleIterator_containsIterator, 0, 0, 1)
ZEND_ARG_OBJ_INFO(0, iterator, Iterator, 0)
ZEND_END_ARG_INFO();
diff --git a/ext/spl/spl_sxe.c b/ext/spl/spl_sxe.c
new file mode 100755
index 0000000000..5670ab6138
--- /dev/null
+++ b/ext/spl/spl_sxe.c
@@ -0,0 +1,196 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2008 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+ */
+
+/* $Id$ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "ext/standard/info.h"
+#include "zend_interfaces.h"
+
+#include "php_spl.h"
+#include "spl_functions.h"
+#include "spl_engine.h"
+#include "spl_iterators.h"
+#include "spl_sxe.h"
+#include "spl_array.h"
+
+zend_class_entry *spl_ce_SimpleXMLIterator = NULL;
+zend_class_entry *spl_ce_SimpleXMLElement;
+
+#if HAVE_LIBXML && HAVE_SIMPLEXML
+
+#include "ext/simplexml/php_simplexml_exports.h"
+
+/* {{{ proto void SimpleXMLIterator::rewind()
+ Rewind to first element */
+SPL_METHOD(SimpleXMLIterator, rewind)
+{
+ php_sxe_iterator iter;
+
+ iter.sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+ spl_ce_SimpleXMLElement->iterator_funcs.funcs->rewind((zend_object_iterator*)&iter TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto bool SimpleXMLIterator::valid()
+ Check whether iteration is valid */
+SPL_METHOD(SimpleXMLIterator, valid)
+{
+ php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+
+ RETURN_BOOL(sxe->iter.data);
+}
+/* }}} */
+
+/* {{{ proto SimpleXMLIterator SimpleXMLIterator::current()
+ Get current element */
+SPL_METHOD(SimpleXMLIterator, current)
+{
+ php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+
+ if (!sxe->iter.data) {
+ return; /* return NULL */
+ }
+
+ RETURN_ZVAL(sxe->iter.data, 1, 0);
+}
+/* }}} */
+
+/* {{{ proto string SimpleXMLIterator::key()
+ Get name of current child element */
+SPL_METHOD(SimpleXMLIterator, key)
+{
+ xmlNodePtr curnode;
+ php_sxe_object *intern;
+ php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+
+ if (!sxe->iter.data) {
+ RETURN_FALSE;
+ }
+
+ intern = (php_sxe_object *)zend_object_store_get_object(sxe->iter.data TSRMLS_CC);
+ if (intern != NULL && intern->node != NULL) {
+ curnode = (xmlNodePtr)((php_libxml_node_ptr *)intern->node)->node;
+ RETURN_STRINGL((char*)curnode->name, xmlStrlen(curnode->name), 1);
+ }
+
+ RETURN_FALSE;
+}
+/* }}} */
+
+/* {{{ proto void SimpleXMLIterator::next()
+ Move to next element */
+SPL_METHOD(SimpleXMLIterator, next)
+{
+ php_sxe_iterator iter;
+
+ iter.sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+ spl_ce_SimpleXMLElement->iterator_funcs.funcs->move_forward((zend_object_iterator*)&iter TSRMLS_CC);
+}
+/* }}} */
+
+/* {{{ proto bool SimpleXMLIterator::hasChildren()
+ Check whether element has children (elements) */
+SPL_METHOD(SimpleXMLIterator, hasChildren)
+{
+ php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+ php_sxe_object *child;
+ xmlNodePtr node;
+
+ if (!sxe->iter.data || sxe->iter.type == SXE_ITER_ATTRLIST) {
+ RETURN_FALSE;
+ }
+ child = php_sxe_fetch_object(sxe->iter.data TSRMLS_CC);
+
+ GET_NODE(child, node);
+ if (node) {
+ node = node->children;
+ }
+ while (node && node->type != XML_ELEMENT_NODE) {
+ node = node->next;
+ }
+ RETURN_BOOL(node ? 1 : 0);
+}
+/* }}} */
+
+/* {{{ proto SimpleXMLIterator SimpleXMLIterator::getChildren()
+ Get child element iterator */
+SPL_METHOD(SimpleXMLIterator, getChildren)
+{
+ php_sxe_object *sxe = php_sxe_fetch_object(getThis() TSRMLS_CC);
+
+ if (!sxe->iter.data || sxe->iter.type == SXE_ITER_ATTRLIST) {
+ return; /* return NULL */
+ }
+ RETURN_ZVAL(sxe->iter.data, 1, 0);
+}
+
+static const zend_function_entry spl_funcs_SimpleXMLIterator[] = {
+ SPL_ME(SimpleXMLIterator, rewind, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(SimpleXMLIterator, valid, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(SimpleXMLIterator, current, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(SimpleXMLIterator, key, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(SimpleXMLIterator, next, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(SimpleXMLIterator, hasChildren, NULL, ZEND_ACC_PUBLIC)
+ SPL_ME(SimpleXMLIterator, getChildren, NULL, ZEND_ACC_PUBLIC)
+ {NULL, NULL, NULL}
+};
+/* }}} */
+
+SPL_API PHP_MINIT_FUNCTION(spl_sxe) /* {{{ */
+{
+ zend_class_entry **pce;
+
+ if (zend_hash_find(CG(class_table), "simplexmlelement", sizeof("SimpleXMLElement"), (void **) &pce) == FAILURE) {
+ spl_ce_SimpleXMLElement = NULL;
+ spl_ce_SimpleXMLIterator = NULL;
+ return SUCCESS; /* SimpleXML must be initialized before */
+ }
+
+ spl_ce_SimpleXMLElement = *pce;
+
+ REGISTER_SPL_SUB_CLASS_EX(SimpleXMLIterator, SimpleXMLElement, spl_ce_SimpleXMLElement->create_object, spl_funcs_SimpleXMLIterator);
+ REGISTER_SPL_IMPLEMENTS(SimpleXMLIterator, RecursiveIterator);
+ REGISTER_SPL_IMPLEMENTS(SimpleXMLIterator, Countable);
+
+ return SUCCESS;
+}
+/* }}} */
+
+#else /* HAVE_LIBXML && HAVE_SIMPLEXML */
+
+SPL_API PHP_MINIT_FUNCTION(spl_sxe) /* {{{ */
+{
+ return SUCCESS;
+}
+
+#endif /* HAVE_LIBXML && HAVE_SIMPLEXML */
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: fdm=marker
+ * vim: noet sw=4 ts=4
+ */
diff --git a/ext/spl/spl_sxe.h b/ext/spl/spl_sxe.h
new file mode 100755
index 0000000000..eca993e4ae
--- /dev/null
+++ b/ext/spl/spl_sxe.h
@@ -0,0 +1,40 @@
+/*
+ +----------------------------------------------------------------------+
+ | PHP Version 5 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997-2008 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 3.01 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available through the world-wide-web at the following url: |
+ | http://www.php.net/license/3_01.txt |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Marcus Boerger <helly@php.net> |
+ +----------------------------------------------------------------------+
+ */
+
+/* $Id$ */
+
+#ifndef SPL_SXE_H
+#define SPL_SXE_H
+
+#include "php.h"
+#include "php_spl.h"
+
+extern zend_class_entry *spl_ce_SimpleXMLIterator;
+
+SPL_API PHP_MINIT_FUNCTION(spl_sxe);
+
+#endif /* SPL_SXE_H */
+
+/*
+ * Local Variables:
+ * c-basic-offset: 4
+ * tab-width: 4
+ * End:
+ * vim600: fdm=marker
+ * vim: noet sw=4 ts=4
+ */
diff --git a/ext/spl/tests/array_001.phpt b/ext/spl/tests/array_001.phpt
index d9fb57c4ce..9f4f35057f 100755
--- a/ext/spl/tests/array_001.phpt
+++ b/ext/spl/tests/array_001.phpt
@@ -36,7 +36,7 @@ var_dump($ar);
===DONE===
<?php exit(0); ?>
--EXPECTF--
-object(ArrayObject)#%d (1) {
+object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(2) {
[0]=>
@@ -62,7 +62,7 @@ array(6) {
int(5)
}
string(1) "a"
-object(ArrayObject)#%d (1) {
+object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(5) {
[0]=>
@@ -88,7 +88,7 @@ NULL
Notice: Undefined offset: 7 in %sarray_001.php on line %d
Notice: Undefined index: c in %sarray_001.php on line %d
-object(ArrayObject)#%d (1) {
+object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(2) {
[0]=>
@@ -97,7 +97,7 @@ object(ArrayObject)#%d (1) {
int(2)
}
}
-object(ArrayObject)#%d (1) {
+object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(4) {
[0]=>
diff --git a/ext/spl/tests/bug42259.phpt b/ext/spl/tests/bug42259.phpt
new file mode 100644
index 0000000000..19c02a577a
--- /dev/null
+++ b/ext/spl/tests/bug42259.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Bug #42259 (SimpleXMLIterator loses ancestry)
+--SKIPIF--
+<?php
+if (!extension_loaded('simplexml')) print 'skip';
+if (!extension_loaded("libxml")) print "skip LibXML not present";
+?>
+--FILE--
+<?php
+$xml =<<<EOF
+<xml>
+ <fieldset1>
+ <field1/>
+ <field2/>
+ </fieldset1>
+ <fieldset2>
+ <options>
+ <option1/>
+ <option2/>
+ <option3/>
+ </options>
+ <field1/>
+ <field2/>
+ </fieldset2>
+</xml>
+EOF;
+
+$sxe = new SimpleXMLIterator($xml);
+$rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::LEAVES_ONLY);
+foreach ($rit as $child) {
+ $path = '';
+ $ancestry = $child->xpath('ancestor-or-self::*');
+ foreach ($ancestry as $ancestor) {
+ $path .= $ancestor->getName() . '/';
+ }
+ $path = substr($path, 0, strlen($path) - 1);
+ echo count($ancestry) . ' steps: ' . $path . PHP_EOL;
+}
+?>
+===DONE===
+--EXPECT--
+3 steps: xml/fieldset1/field1
+3 steps: xml/fieldset1/field2
+4 steps: xml/fieldset2/options/option1
+4 steps: xml/fieldset2/options/option2
+4 steps: xml/fieldset2/options/option3
+3 steps: xml/fieldset2/field1
+3 steps: xml/fieldset2/field2
+===DONE===
diff --git a/ext/spl/tests/heap_007.phpt b/ext/spl/tests/heap_007.phpt
index e8d5c9997c..784ac6e8b0 100644
--- a/ext/spl/tests/heap_007.phpt
+++ b/ext/spl/tests/heap_007.phpt
@@ -12,7 +12,6 @@ $h->insert(4);
$h->rewind();
echo "count(\$h) = ".count($h)."\n";
echo "\$h->count() = ".$h->count()."\n";
-
while ($h->valid()) {
$k = $h->key();
$v = $h->current();
@@ -25,8 +24,8 @@ while ($h->valid()) {
--EXPECTF--
count($h) = 4
$h->count() = 4
-3=>5
-2=>4
-1=>1
-0=>0
+4=>5
+3=>4
+2=>1
+1=>0
===DONE===
diff --git a/ext/spl/tests/pqueue_003.phpt b/ext/spl/tests/pqueue_003.phpt
index 9c0b5a5147..8abc72c4c7 100644
--- a/ext/spl/tests/pqueue_003.phpt
+++ b/ext/spl/tests/pqueue_003.phpt
@@ -24,8 +24,8 @@ while ($h->valid()) {
--EXPECTF--
count($h) = 4
$h->count() = 4
-3=>5
-2=>4
-1=>1
-0=>0
+4=>5
+3=>4
+2=>1
+1=>0
===DONE===
diff --git a/ext/spl/tests/spl_autoload_012.phpt b/ext/spl/tests/spl_autoload_012.phpt
index e07f0e4fe5..07e9dfeb63 100755
--- a/ext/spl/tests/spl_autoload_012.phpt
+++ b/ext/spl/tests/spl_autoload_012.phpt
@@ -26,14 +26,6 @@ try {
} while($e = $e->getPrevious());
}
-try {
- new ThisClassDoesNotExist;
-} catch(Exception $e) {
- do {
- echo $e->getMessage()."\n";
- } while($e = $e->getPrevious());
-}
-
class_exists('ThisClassDoesNotExist');
?>
===DONE===
@@ -44,10 +36,6 @@ second
first
autoload_first
autoload_second
-second
-first
-autoload_first
-autoload_second
Fatal error: Uncaught exception 'Exception' with message 'first' in %sspl_autoload_012.php:%d
Stack trace:
diff --git a/ext/spl/tests/sxe_001.phpt b/ext/spl/tests/sxe_001.phpt
new file mode 100755
index 0000000000..bb93eea076
--- /dev/null
+++ b/ext/spl/tests/sxe_001.phpt
@@ -0,0 +1,63 @@
+--TEST--
+SPL: SimpleXMLIterator
+--SKIPIF--
+<?php
+if (!extension_loaded("simplexml")) print "skip SimpleXML not present";
+if (!extension_loaded("libxml")) print "skip LibXML not present";
+?>
+--FILE--
+<?php
+
+$xml =<<<EOF
+<?xml version='1.0'?>
+<!DOCTYPE sxe SYSTEM "notfound.dtd">
+<sxe id="elem1">
+ <elem1 attr1='first'>
+ <!-- comment -->
+ <elem2>
+ <elem3>
+ <elem4>
+ <?test processing instruction ?>
+ </elem4>
+ </elem3>
+ </elem2>
+ </elem1>
+</sxe>
+EOF;
+
+var_dump(simplexml_load_string((binary)$xml, 'SimpleXMLIterator'));
+
+?>
+===DONE===
+--EXPECTF--
+object(SimpleXMLIterator)#%d (2) {
+ ["@attributes"]=>
+ array(1) {
+ ["id"]=>
+ string(5) "elem1"
+ }
+ ["elem1"]=>
+ object(SimpleXMLIterator)#%d (3) {
+ ["@attributes"]=>
+ array(1) {
+ ["attr1"]=>
+ string(5) "first"
+ }
+ ["comment"]=>
+ object(SimpleXMLIterator)#%d (0) {
+ }
+ ["elem2"]=>
+ object(SimpleXMLIterator)#%d (1) {
+ ["elem3"]=>
+ object(SimpleXMLIterator)#%d (1) {
+ ["elem4"]=>
+ object(SimpleXMLIterator)#%d (1) {
+ ["test"]=>
+ object(SimpleXMLIterator)#%d (0) {
+ }
+ }
+ }
+ }
+ }
+}
+===DONE===
diff --git a/ext/spl/tests/sxe_002.phpt b/ext/spl/tests/sxe_002.phpt
new file mode 100755
index 0000000000..b937b011d0
--- /dev/null
+++ b/ext/spl/tests/sxe_002.phpt
@@ -0,0 +1,75 @@
+--TEST--
+SPL: SimpleXMLIterator and recursion
+--SKIPIF--
+<?php
+if (!extension_loaded('simplexml')) print 'skip';
+if (!extension_loaded("libxml")) print "skip LibXML not present";
+?>
+--FILE--
+<?php
+
+$xml =<<<EOF
+<?xml version='1.0'?>
+<!DOCTYPE sxe SYSTEM "notfound.dtd">
+<sxe id="elem1">
+ Plain text.
+ <elem1 attr1='first'>
+ Bla bla 1.
+ <!-- comment -->
+ <elem2>
+ Here we have some text data.
+ <elem3>
+ And here some more.
+ <elem4>
+ Wow once again.
+ </elem4>
+ </elem3>
+ </elem2>
+ </elem1>
+ <elem11 attr2='second'>
+ Bla bla 2.
+ <elem111>
+ Foo Bar
+ </elem111>
+ </elem11>
+</sxe>
+EOF;
+
+$sxe = simplexml_load_string((binary)$xml, 'SimpleXMLIterator');
+
+foreach(new RecursiveIteratorIterator($sxe, 1) as $name => $data) {
+ var_dump($name);
+ var_dump(get_class($data));
+ var_dump(trim($data));
+}
+
+echo "===DUMP===\n";
+
+var_dump(get_class($sxe));
+var_dump(trim($sxe->elem1));
+
+?>
+===DONE===
+--EXPECT--
+string(5) "elem1"
+string(17) "SimpleXMLIterator"
+string(10) "Bla bla 1."
+string(5) "elem2"
+string(17) "SimpleXMLIterator"
+string(28) "Here we have some text data."
+string(5) "elem3"
+string(17) "SimpleXMLIterator"
+string(19) "And here some more."
+string(5) "elem4"
+string(17) "SimpleXMLIterator"
+string(15) "Wow once again."
+string(6) "elem11"
+string(17) "SimpleXMLIterator"
+string(10) "Bla bla 2."
+string(7) "elem111"
+string(17) "SimpleXMLIterator"
+string(7) "Foo Bar"
+===DUMP===
+string(17) "SimpleXMLIterator"
+string(10) "Bla bla 1."
+===DONE===
diff --git a/ext/spl/tests/sxe_003.phpt b/ext/spl/tests/sxe_003.phpt
new file mode 100755
index 0000000000..58c7523160
--- /dev/null
+++ b/ext/spl/tests/sxe_003.phpt
@@ -0,0 +1,77 @@
+--TEST--
+SPL: SimpleXMLIterator and getChildren()
+--SKIPIF--
+<?php
+if (!extension_loaded('simplexml')) print 'skip';
+if (!extension_loaded("libxml")) print "skip LibXML not present";
+?>
+--FILE--
+<?php
+
+$xml =<<<EOF
+<?xml version='1.0'?>
+<!DOCTYPE sxe SYSTEM "notfound.dtd">
+<sxe id="elem1">
+ Plain text.
+ <elem1 attr1='first'>
+ Bla bla 1.
+ <!-- comment -->
+ <elem2>
+ Here we have some text data.
+ <elem3>
+ And here some more.
+ <elem4>
+ Wow once again.
+ </elem4>
+ </elem3>
+ </elem2>
+ </elem1>
+ <elem11 attr2='second'>
+ Bla bla 2.
+ <elem111>
+ Foo Bar
+ </elem111>
+ </elem11>
+</sxe>
+EOF;
+
+$sxe = simplexml_load_string((binary)$xml, 'SimpleXMLIterator');
+
+foreach($sxe->getChildren() as $name => $data) {
+ var_dump($name);
+ var_dump(get_class($data));
+ var_dump(trim($data));
+}
+
+echo "===RESET===\n";
+
+for ($sxe->rewind(); $sxe->valid(); $sxe->next()) {
+ var_dump($sxe->hasChildren());
+ var_dump(trim($sxe->key()));
+ var_dump(trim($sxe->current()));
+ foreach($sxe->getChildren() as $name => $data) {
+ var_dump($name);
+ var_dump(get_class($data));
+ var_dump(trim($data));
+ }
+}
+
+?>
+===DONE===
+--EXPECTF--
+
+Warning: Invalid argument supplied for foreach() in %ssxe_003.php on line %d
+===RESET===
+bool(true)
+string(5) "elem1"
+string(10) "Bla bla 1."
+string(5) "elem2"
+string(17) "SimpleXMLIterator"
+string(28) "Here we have some text data."
+bool(true)
+string(6) "elem11"
+string(10) "Bla bla 2."
+string(7) "elem111"
+string(17) "SimpleXMLIterator"
+string(7) "Foo Bar"
+===DONE===
diff --git a/ext/spl/tests/sxe_004.phpt b/ext/spl/tests/sxe_004.phpt
new file mode 100755
index 0000000000..20431de8be
--- /dev/null
+++ b/ext/spl/tests/sxe_004.phpt
@@ -0,0 +1,145 @@
+--TEST--
+SPL: SimpleXMLIterator and overridden iterator methods()
+--SKIPIF--
+<?php
+if (!extension_loaded('simplexml')) print 'skip';
+if (!extension_loaded("libxml")) print "skip LibXML not present";
+?>
+--FILE--
+<?php
+
+$xml =<<<EOF
+<?xml version='1.0'?>
+<!DOCTYPE sxe SYSTEM "notfound.dtd">
+<sxe id="elem1">
+ Plain text.
+ <elem1 attr1='first'>
+ Bla bla 1.
+ <!-- comment -->
+ <elem2>
+ Here we have some text data.
+ <elem3>
+ And here some more.
+ <elem4>
+ Wow once again.
+ </elem4>
+ </elem3>
+ </elem2>
+ </elem1>
+ <elem11 attr2='second'>
+ Bla bla 2.
+ <elem111>
+ Foo Bar
+ </elem111>
+ </elem11>
+</sxe>
+EOF;
+
+class SXETest extends SimpleXMLIterator
+{
+ function rewind()
+ {
+ echo __METHOD__ . "\n";
+ return parent::rewind();
+ }
+ function valid()
+ {
+ echo __METHOD__ . "\n";
+ return parent::valid();
+ }
+ function current()
+ {
+ echo __METHOD__ . "\n";
+ return parent::current();
+ }
+ function key()
+ {
+ echo __METHOD__ . "\n";
+ return parent::key();
+ }
+ function next()
+ {
+ echo __METHOD__ . "\n";
+ return parent::next();
+ }
+ function hasChildren()
+ {
+ echo __METHOD__ . "\n";
+ return parent::hasChildren();
+ }
+ function getChildren()
+ {
+ echo __METHOD__ . "\n";
+ return parent::getChildren();
+ }
+}
+
+$sxe = new SXETest((binary)$xml);
+$rit = new RecursiveIteratorIterator($sxe, RecursiveIteratorIterator::SELF_FIRST);
+
+foreach($rit as $data) {
+ var_dump(get_class($data));
+ var_dump(trim($data));
+}
+
+?>
+===DONE===
+--EXPECTF--
+SXETest::rewind
+SXETest::valid
+SXETest::hasChildren
+SXETest::valid
+SXETest::current
+string(7) "SXETest"
+string(10) "Bla bla 1."
+SXETest::getChildren
+SXETest::rewind
+SXETest::valid
+SXETest::hasChildren
+SXETest::valid
+SXETest::current
+string(7) "SXETest"
+string(28) "Here we have some text data."
+SXETest::getChildren
+SXETest::rewind
+SXETest::valid
+SXETest::hasChildren
+SXETest::valid
+SXETest::current
+string(7) "SXETest"
+string(19) "And here some more."
+SXETest::getChildren
+SXETest::rewind
+SXETest::valid
+SXETest::hasChildren
+SXETest::valid
+SXETest::current
+string(7) "SXETest"
+string(15) "Wow once again."
+SXETest::next
+SXETest::valid
+SXETest::next
+SXETest::valid
+SXETest::next
+SXETest::valid
+SXETest::next
+SXETest::valid
+SXETest::hasChildren
+SXETest::valid
+SXETest::current
+string(7) "SXETest"
+string(10) "Bla bla 2."
+SXETest::getChildren
+SXETest::rewind
+SXETest::valid
+SXETest::hasChildren
+SXETest::valid
+SXETest::current
+string(7) "SXETest"
+string(7) "Foo Bar"
+SXETest::next
+SXETest::valid
+SXETest::next
+SXETest::valid
+SXETest::valid
+===DONE===
diff --git a/ext/spl/tests/sxe_005.phpt b/ext/spl/tests/sxe_005.phpt
new file mode 100755
index 0000000000..183d351166
--- /dev/null
+++ b/ext/spl/tests/sxe_005.phpt
@@ -0,0 +1,44 @@
+--TEST--
+SPL: SimpleXMLIterator and overriden count()
+--SKIPIF--
+<?php
+if (!extension_loaded('simplexml')) print 'skip';
+if (!extension_loaded("libxml")) print "skip LibXML not present";
+?>
+--FILE--
+<?php
+
+$xml =<<<EOF
+<?xml version='1.0'?>
+<sxe>
+ <elem1/>
+ <elem2/>
+ <elem2/>
+</sxe>
+EOF;
+
+class SXETest extends SimpleXMLIterator
+{
+ function count()
+ {
+ echo __METHOD__ . "\n";
+ return parent::count();
+ }
+}
+
+$sxe = new SXETest((binary)$xml);
+
+var_dump(count($sxe));
+var_dump(count($sxe->elem1));
+var_dump(count($sxe->elem2));
+
+?>
+===DONE===
+--EXPECT--
+SXETest::count
+int(3)
+SXETest::count
+int(1)
+SXETest::count
+int(2)
+===DONE===