diff options
Diffstat (limited to 'ext/spl')
33 files changed, 191 insertions, 86 deletions
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c index 8e172efde..1ce09fe04 100755 --- a/ext/spl/php_spl.c +++ b/ext/spl/php_spl.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_spl.c 313665 2011-07-25 11:42:53Z felipe $ */ +/* $Id: php_spl.c 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H #include "config.h" @@ -406,6 +406,7 @@ PHP_FUNCTION(spl_autoload_call) zend_exception_save(TSRMLS_C); if (retval) { zval_ptr_dtor(&retval); + retval = NULL; } if (zend_hash_exists(EG(class_table), lc_name, class_name_len + 1)) { break; diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h index bafaf53d4..fb0765a81 100755 --- a/ext/spl/php_spl.h +++ b/ext/spl/php_spl.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index be24d48ed..c6cef638c 100755 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_array.c 313665 2011-07-25 11:42:53Z felipe $ */ +/* $Id: spl_array.c 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -77,6 +77,7 @@ typedef struct _spl_array_object { php_serialize_data_t *serialize_data; php_unserialize_data_t *unserialize_data; HashTable *debug_info; + unsigned char nApplyCount; } spl_array_object; static inline HashTable *spl_array_get_hash_table(spl_array_object* intern, int check_std_props TSRMLS_DC) { /* {{{ */ @@ -728,8 +729,16 @@ SPL_METHOD(Array, getArrayCopy) static HashTable *spl_array_get_properties(zval *object TSRMLS_DC) /* {{{ */ { spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); + HashTable *result; - return spl_array_get_hash_table(intern, 1 TSRMLS_CC); + 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; } /* }}} */ static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp TSRMLS_DC) /* {{{ */ diff --git a/ext/spl/spl_array.h b/ext/spl/spl_array.h index 90b8e6629..b2280e613 100755 --- a/ext/spl/spl_array.h +++ b/ext/spl/spl_array.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_array.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_array.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef SPL_ARRAY_H #define SPL_ARRAY_H diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index b7560915c..76183c550 100755 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_directory.c 313665 2011-07-25 11:42:53Z felipe $ */ +/* $Id: spl_directory.c 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -1215,7 +1215,10 @@ SPL_METHOD(SplFileInfo, getLinkTarget) zend_replace_error_handling(EH_THROW, spl_ce_RuntimeException, &error_handling TSRMLS_CC); #if defined(PHP_WIN32) || HAVE_SYMLINK - if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) { + if (intern->file_name == NULL) { + php_error_docref(NULL TSRMLS_CC, E_WARNING, "Empty filename"); + RETURN_FALSE; + } else if (!IS_ABSOLUTE_PATH(intern->file_name, intern->file_name_len)) { char expanded_path[MAXPATHLEN]; /* TODO: Fix expand_filepath to do not resolve links but only expand the path diff --git a/ext/spl/spl_directory.h b/ext/spl/spl_directory.h index 1d97efedb..ec31b09bb 100755 --- a/ext/spl/spl_directory.h +++ b/ext/spl/spl_directory.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_directory.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_directory.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef SPL_DIRECTORY_H #define SPL_DIRECTORY_H @@ -117,7 +117,7 @@ static inline spl_filesystem_object* spl_filesystem_iterator_to_object(spl_files #define SPL_FILE_OBJECT_DROP_NEW_LINE 0x00000001 /* drop new lines */ #define SPL_FILE_OBJECT_READ_AHEAD 0x00000002 /* read on rewind/next */ -#define SPL_FILE_OBJECT_SKIP_EMPTY 0x00000006 /* skip empty lines */ +#define SPL_FILE_OBJECT_SKIP_EMPTY 0x00000004 /* skip empty lines */ #define SPL_FILE_OBJECT_READ_CSV 0x00000008 /* read via fgetcsv */ #define SPL_FILE_OBJECT_MASK 0x0000000F /* read via fgetcsv */ diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index 7db3885c2..3533ec4d9 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_dllist.c 313665 2011-07-25 11:42:53Z felipe $ */ +/* $Id: spl_dllist.c 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H # include "config.h" diff --git a/ext/spl/spl_dllist.h b/ext/spl/spl_dllist.h index 3bb8c28f1..dec421966 100644 --- a/ext/spl/spl_dllist.h +++ b/ext/spl/spl_dllist.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_dllist.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_dllist.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef SPL_DLLIST_H #define SPL_DLLIST_H diff --git a/ext/spl/spl_engine.c b/ext/spl/spl_engine.c index 0e922c564..9273308b1 100755 --- a/ext/spl/spl_engine.c +++ b/ext/spl/spl_engine.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | diff --git a/ext/spl/spl_engine.h b/ext/spl/spl_engine.h index f6c5f5ff1..c0d044bc3 100755 --- a/ext/spl/spl_engine.h +++ b/ext/spl/spl_engine.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_engine.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_engine.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef SPL_ENGINE_H #define SPL_ENGINE_H diff --git a/ext/spl/spl_exceptions.c b/ext/spl/spl_exceptions.c index 3cdcd1f7e..fe3f4b1e1 100755 --- a/ext/spl/spl_exceptions.c +++ b/ext/spl/spl_exceptions.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_exceptions.c 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_exceptions.c 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H # include "config.h" diff --git a/ext/spl/spl_exceptions.h b/ext/spl/spl_exceptions.h index 3f0808db7..3c9c05788 100755 --- a/ext/spl/spl_exceptions.h +++ b/ext/spl/spl_exceptions.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_exceptions.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_exceptions.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef SPL_EXCEPTIONS_H #define SPL_EXCEPTIONS_H diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 54b457b50..ad270ca52 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_fixedarray.c 313665 2011-07-25 11:42:53Z felipe $ */ +/* $Id: spl_fixedarray.c 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/ext/spl/spl_fixedarray.h b/ext/spl/spl_fixedarray.h index a85ddb98e..071da5449 100644 --- a/ext/spl/spl_fixedarray.h +++ b/ext/spl/spl_fixedarray.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_fixedarray.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_fixedarray.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef SPL_FIXEDARRAY_H #define SPL_FIXEDARRAY_H diff --git a/ext/spl/spl_functions.c b/ext/spl/spl_functions.c index 48481f326..2c91ba9e5 100755 --- a/ext/spl/spl_functions.c +++ b/ext/spl/spl_functions.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_functions.c 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_functions.c 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/ext/spl/spl_functions.h b/ext/spl/spl_functions.h index eb96ff611..f5a4195ab 100755 --- a/ext/spl/spl_functions.h +++ b/ext/spl/spl_functions.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_functions.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_functions.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef PHP_FUNCTIONS_H #define PHP_FUNCTIONS_H diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index 1001b3b3c..5152ce63d 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_heap.c 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_heap.c 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H # include "config.h" diff --git a/ext/spl/spl_heap.h b/ext/spl/spl_heap.h index 43bba03e1..13592821f 100644 --- a/ext/spl/spl_heap.h +++ b/ext/spl/spl_heap.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_heap.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_heap.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef SPL_HEAP_H #define SPL_HEAP_H diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index 3ef0595c3..369a17905 100755 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_iterators.c 313665 2011-07-25 11:42:53Z felipe $ */ +/* $Id: spl_iterators.c 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -1868,7 +1868,7 @@ SPL_METHOD(RegexIterator, accept) spl_dual_it_object *intern; char *subject, tmp[32], *result; int subject_len, use_copy, count = 0, result_len; - zval subject_copy, zcount, *replacement; + zval subject_copy, zcount, *replacement, tmp_replacement; if (zend_parse_parameters_none() == FAILURE) { return; @@ -1937,6 +1937,12 @@ SPL_METHOD(RegexIterator, accept) case REGIT_MODE_REPLACE: replacement = zend_read_property(intern->std.ce, getThis(), "replacement", sizeof("replacement")-1, 1 TSRMLS_CC); + if (Z_TYPE_P(replacement) != IS_STRING) { + tmp_replacement = *replacement; + zval_copy_ctor(&tmp_replacement); + convert_to_string(&tmp_replacement); + replacement = &tmp_replacement; + } result = php_pcre_replace_impl(intern->u.regex.pce, subject, subject_len, replacement, 0, &result_len, -1, &count TSRMLS_CC); if (intern->u.regex.flags & REGIT_USE_KEY) { @@ -1951,6 +1957,10 @@ SPL_METHOD(RegexIterator, accept) MAKE_STD_ZVAL(intern->current.data); ZVAL_STRINGL(intern->current.data, result, result_len, 0); } + + if (replacement == &tmp_replacement) { + zval_dtor(replacement); + } RETVAL_BOOL(count > 0); } diff --git a/ext/spl/spl_iterators.h b/ext/spl/spl_iterators.h index dadd3a555..95aba831a 100755 --- a/ext/spl/spl_iterators.h +++ b/ext/spl/spl_iterators.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_iterators.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_iterators.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef SPL_ITERATORS_H #define SPL_ITERATORS_H diff --git a/ext/spl/spl_observer.c b/ext/spl/spl_observer.c index b41853032..c692734fe 100755 --- a/ext/spl/spl_observer.c +++ b/ext/spl/spl_observer.c @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 The PHP Group | +----------------------------------------------------------------------+ | This source file is SplSubject to version 3.01 of the PHP license, | | that is bundled with this package in the file LICENSE, and is | @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_observer.c 308784 2011-03-01 00:13:23Z felipe $ */ +/* $Id: spl_observer.c 321634 2012-01-01 13:15:04Z felipe $ */ #ifdef HAVE_CONFIG_H # include "config.h" diff --git a/ext/spl/spl_observer.h b/ext/spl/spl_observer.h index ef246a068..4e85ce8b2 100755 --- a/ext/spl/spl_observer.h +++ b/ext/spl/spl_observer.h @@ -2,7 +2,7 @@ +----------------------------------------------------------------------+ | PHP Version 5 | +----------------------------------------------------------------------+ - | Copyright (c) 1997-2011 The PHP Group | + | Copyright (c) 1997-2012 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 | @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: spl_observer.h 306939 2011-01-01 02:19:59Z felipe $ */ +/* $Id: spl_observer.h 321634 2012-01-01 13:15:04Z felipe $ */ #ifndef SPL_OBSERVER_H #define SPL_OBSERVER_H diff --git a/ext/spl/tests/DirectoryIterator_by_reference.phpt b/ext/spl/tests/DirectoryIterator_by_reference.phpt index 5352a5df1..06127ec37 100644 --- a/ext/spl/tests/DirectoryIterator_by_reference.phpt +++ b/ext/spl/tests/DirectoryIterator_by_reference.phpt @@ -5,10 +5,10 @@ Havard Eide <nucleuz@gmail.com> #PHPTestFest2009 Norway 2009-06-09 \o/ --FILE-- <?php -$it = new DirectoryIterator("/tmp"); +$it = new DirectoryIterator(__DIR__); foreach( $it as &$file ) { echo $file . "\n"; } ?> --EXPECTF-- -Fatal error: An iterator cannot be used with foreach by reference in %s on line %d
\ No newline at end of file +Fatal error: An iterator cannot be used with foreach by reference in %s on line %d diff --git a/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt b/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt index 20ef3bf36..7398d4b9d 100644 --- a/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt +++ b/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt @@ -1,5 +1,11 @@ --TEST-- SPL: DirectoryIterator::getExtension() basic test +--SKIPIF-- +<?php +if (substr(PHP_OS, 0, 3) == 'WIN') { + die('skip.. only for Unix'); +} +?> --FILE-- <?php $dir = __DIR__ . DIRECTORY_SEPARATOR . md5('DirectoryIterator::getExtension') . DIRECTORY_SEPARATOR; diff --git a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt index 9cc9fadbe..0c75bf4c0 100644 --- a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt +++ b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt @@ -1,15 +1,18 @@ ---TEST--
-SPL: DirectoryIterator test getGroup
---CREDITS--
+--TEST-- +SPL: DirectoryIterator test getGroup +--SKIPIF-- +<?php +if (posix_geteuid() == 0) die('SKIP Cannot run test as root.'); +--CREDITS-- Cesare D'Amico <cesare.damico@gruppovolta.it> Andrea Giorgini <agiorg@gmail.com> Filippo De Santis <fd@ideato.it> Daniel Londero <daniel.londero@gmail.com> Francesco Trucchia <ft@ideato.it> Jacopo Romei <jacopo@sviluppoagile.it> -#Test Fest Cesena (Italy) on 2009-06-20
---FILE--
-<?php
+#Test Fest Cesena (Italy) on 2009-06-20 +--FILE-- +<?php $dirname = 'DirectoryIterator_getGroup_basic'; mkdir($dirname); $dir = new DirectoryIterator($dirname); @@ -21,6 +24,6 @@ var_dump($expected == $actual); <?php $dirname = 'DirectoryIterator_getGroup_basic'; rmdir($dirname); -?>
---EXPECTF--
+?> +--EXPECTF-- bool(true) diff --git a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt index c5e9f7c2c..a1092c2fe 100644 --- a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt +++ b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt @@ -1,5 +1,8 @@ --TEST-- SPL: DirectoryIterator test getOwner +--SKIPIF-- +<?php +if (posix_geteuid() == 0) die('SKIP Cannot run test as root.'); --CREDITS-- Cesare D'Amico <cesare.damico@gruppovolta.it> Andrea Giorgini <agiorg@gmail.com> diff --git a/ext/spl/tests/SplFileInfo_getGroup_basic.phpt b/ext/spl/tests/SplFileInfo_getGroup_basic.phpt index c5808c57d..d27993563 100644 --- a/ext/spl/tests/SplFileInfo_getGroup_basic.phpt +++ b/ext/spl/tests/SplFileInfo_getGroup_basic.phpt @@ -10,7 +10,7 @@ Jacopo Romei <jacopo@sviluppoagile.it> #Test Fest Cesena (Italy) on 2009-06-20 --FILE-- <?php -$filename = basename(__FILE__, 'phpt').'tmp'; +$filename = __DIR__ . "/SplFileInfo_getGroup_basic"; touch($filename); $fileInfo = new SplFileInfo($filename); $expected = filegroup($filename); @@ -19,7 +19,7 @@ var_dump($expected == $actual); ?> --CLEAN-- <?php -$filename = basename(__FILE__, 'phpt').'tmp'; +$filename = __DIR__ . "/SplFileInfo_getGroup_basic"; unlink($filename); ?> --EXPECTF-- diff --git a/ext/spl/tests/SplFileInfo_getOwner_basic.phpt b/ext/spl/tests/SplFileInfo_getOwner_basic.phpt index 790dcc69b..3df8e4858 100644 --- a/ext/spl/tests/SplFileInfo_getOwner_basic.phpt +++ b/ext/spl/tests/SplFileInfo_getOwner_basic.phpt @@ -10,7 +10,7 @@ Jacopo Romei <jacopo@sviluppoagile.it> #Test Fest Cesena (Italy) on 2009-06-20 --FILE-- <?php -$filename = basename(__FILE__, 'phpt').'tmp'; +$filename = __DIR__ . "/SplFileInfo_getOwner_basic"; touch($filename); $fileInfo = new SplFileInfo($filename); $expected = fileowner($filename); @@ -19,7 +19,7 @@ var_dump($expected == $actual); ?> --CLEAN-- <?php -$filename = basename(__FILE__, 'phpt').'tmp'; +$filename = __DIR__ . "/SplFileInfo_getOwner_basic"; unlink($filename); ?> --EXPECTF-- diff --git a/ext/spl/tests/bug53071.phpt b/ext/spl/tests/bug53071.phpt index b0ea3aad8..c2c2605e2 100644 --- a/ext/spl/tests/bug53071.phpt +++ b/ext/spl/tests/bug53071.phpt @@ -1,26 +1,27 @@ ---TEST--
-Bug #53071 (Usage of SPLObjectStorage defeats gc_collect_cycles)
---FILE--
-<?php
-class myClass
-{
- public $member;
-}
-function LimitedScope()
-{
- $myA = new myClass();
- $myB = new SplObjectStorage();
- $myC = new myClass();
- $myC->member = $myA; // myC has a referece to myA
- $myB->Attach($myC); // myB attaches myC
- $myA->member = $myB; // myA has myB, comleting the cycle
-}
-LimitedScope();
-var_dump(gc_collect_cycles());
-
-echo "Done.\n";
-
-?>
---EXPECTF--
-int(5)
-Done.
+--TEST-- +Bug #53071 (Usage of SPLObjectStorage defeats gc_collect_cycles) +--FILE-- +<?php +gc_enable(); +class myClass +{ + public $member; +} +function LimitedScope() +{ + $myA = new myClass(); + $myB = new SplObjectStorage(); + $myC = new myClass(); + $myC->member = $myA; // myC has a referece to myA + $myB->Attach($myC); // myB attaches myC + $myA->member = $myB; // myA has myB, comleting the cycle +} +LimitedScope(); +var_dump(gc_collect_cycles()); + +echo "Done.\n"; + +?> +--EXPECTF-- +int(5) +Done. diff --git a/ext/spl/tests/bug54304.phpt b/ext/spl/tests/bug54304.phpt new file mode 100644 index 000000000..32cbe486a --- /dev/null +++ b/ext/spl/tests/bug54304.phpt @@ -0,0 +1,26 @@ +--TEST-- +Bug #54304 (Setting replacement value for RegexIterator doesn't work) +--FILE-- +<?php +class foo extends ArrayIterator { + public function __construct( ) { + parent::__construct(array( + 'test3'=>'test999')); + } +} + +$h = new foo; +$i = new RegexIterator($h, '/^test(.*)/', RegexIterator::REPLACE); +$i->replacement = 42; +var_dump($i->replacement); +foreach ($i as $name=>$value) { + var_dump($name, $value); +} +var_dump($i->replacement); +?> +--EXPECT-- +int(42) +string(5) "test3" +string(2) "42" +int(42) + diff --git a/ext/spl/tests/bug54971.phpt b/ext/spl/tests/bug54971.phpt index 166613b43..07a470627 100644 --- a/ext/spl/tests/bug54971.phpt +++ b/ext/spl/tests/bug54971.phpt @@ -1,5 +1,9 @@ --TEST-- Bug #54971 (Wrong result when using iterator_to_array with use_keys on true) +--SKIPIF-- +<?php +if (!extension_loaded('dom')) die("skip this test needs --enable-dom"); +?> --FILE-- <?php diff --git a/ext/spl/tests/bug60082.phpt b/ext/spl/tests/bug60082.phpt new file mode 100755 index 000000000..7aff2c416 --- /dev/null +++ b/ext/spl/tests/bug60082.phpt @@ -0,0 +1,21 @@ +--TEST-- +Bug #60082 (100% CPU / when using references with ArrayObject(&$ref)) +--SKIPIF-- +<?php +if (getenv("SKIP_SLOW_TESTS")) die("skip slow test"); +if ((stristr(PHP_OS, 'freebsd'))) { + die('skip.. this test causes the run-tests.php to hang on Freebsd, see #60186'); +} +?> +--FILE-- +<?php +$test = array(); +$test = new ArrayObject(&$test); +$test['a'] = $test['b']; +?> +===DONE=== +<?php exit(0); ?> +--EXPECTF-- +Deprecated: Call-time pass-by-reference has been deprecated in %sbug60082.php on line %d + +Fatal error: main(): Array was modified outside object and made a recursive object in %sbug60082.php on line %d diff --git a/ext/spl/tests/spl_autoload_call_basic.phpt b/ext/spl/tests/spl_autoload_call_basic.phpt new file mode 100644 index 000000000..2bd65c22b --- /dev/null +++ b/ext/spl/tests/spl_autoload_call_basic.phpt @@ -0,0 +1,18 @@ +--TEST-- +spl_autoload_call() function - basic test for spl_autoload_call() +--CREDITS-- +Jean-Marc Fontaine <jean-marc.fontaine@alterway.fr> +# Alter Way Contribution Day 2011 +--FILE-- +<?php +function customAutolader($class) { + require_once __DIR__ . '/testclass.class.inc'; +} +spl_autoload_register('customAutolader'); + +spl_autoload_call('TestClass'); +var_dump(class_exists('TestClass', false)); +?> +--EXPECTF-- +%stestclass.class.inc +bool(true) |
