summaryrefslogtreecommitdiff
path: root/ext/spl
diff options
context:
space:
mode:
Diffstat (limited to 'ext/spl')
-rw-r--r--[-rwxr-xr-x]ext/spl/CREDITS0
-rwxr-xr-xext/spl/README7
-rw-r--r--[-rwxr-xr-x]ext/spl/config.m49
-rw-r--r--ext/spl/config.w321
-rwxr-xr-xext/spl/doxygen.cfg217
-rw-r--r--ext/spl/examples/autoload.inc50
-rw-r--r--ext/spl/examples/cachingrecursiveiterator.inc28
-rw-r--r--ext/spl/examples/callbackfilteriterator.inc122
-rwxr-xr-xext/spl/examples/class_tree.php113
-rwxr-xr-xext/spl/examples/dba_array.php52
-rwxr-xr-xext/spl/examples/dba_dump.php42
-rw-r--r--ext/spl/examples/dbaarray.inc95
-rw-r--r--ext/spl/examples/dbareader.inc96
-rw-r--r--ext/spl/examples/directoryfilterdots.inc45
-rw-r--r--ext/spl/examples/directorygraphiterator.inc34
-rw-r--r--ext/spl/examples/directorytree.inc27
-rwxr-xr-xext/spl/examples/directorytree.php37
-rw-r--r--ext/spl/examples/directorytreeiterator.inc54
-rw-r--r--ext/spl/examples/findfile.inc65
-rwxr-xr-xext/spl/examples/findfile.php33
-rwxr-xr-xext/spl/examples/findregex.php36
-rwxr-xr-xext/spl/examples/ini_groups.php41
-rw-r--r--ext/spl/examples/inigroups.inc54
-rw-r--r--ext/spl/examples/keyfilter.inc64
-rwxr-xr-xext/spl/examples/nocvsdir.php55
-rwxr-xr-xext/spl/examples/phar_from_dir.php50
-rw-r--r--ext/spl/examples/regexfindfile.inc40
-rw-r--r--ext/spl/examples/searchiterator.inc58
-rw-r--r--ext/spl/examples/tests/examples.inc23
-rwxr-xr-xext/spl/examples/tree.php40
-rw-r--r--ext/spl/internal/appenditerator.inc122
-rw-r--r--ext/spl/internal/cachingiterator.inc157
-rw-r--r--ext/spl/internal/emptyiterator.inc62
-rw-r--r--ext/spl/internal/filteriterator.inc127
-rw-r--r--ext/spl/internal/infiniteiterator.inc48
-rw-r--r--ext/spl/internal/iteratoriterator.inc121
-rw-r--r--ext/spl/internal/limititerator.inc134
-rw-r--r--ext/spl/internal/multipleiterator.inc223
-rw-r--r--ext/spl/internal/norewinditerator.inc28
-rw-r--r--ext/spl/internal/outeriterator.inc25
-rw-r--r--ext/spl/internal/parentiterator.inc32
-rw-r--r--ext/spl/internal/recursivearrayiterator.inc59
-rw-r--r--ext/spl/internal/recursivecachingiterator.inc99
-rw-r--r--ext/spl/internal/recursivefilteriterator.inc62
-rw-r--r--ext/spl/internal/recursiveiterator.inc30
-rw-r--r--ext/spl/internal/recursiveiteratoriterator.inc237
-rw-r--r--ext/spl/internal/recursiveregexiterator.inc61
-rw-r--r--ext/spl/internal/recursivetreeiterator.inc132
-rw-r--r--ext/spl/internal/regexiterator.inc170
-rw-r--r--ext/spl/internal/seekableiterator.inc48
-rw-r--r--ext/spl/internal/spldoublylinkedlist.inc277
-rw-r--r--ext/spl/internal/splfileobject.inc377
-rw-r--r--ext/spl/internal/splobjectstorage.inc188
-rw-r--r--ext/spl/internal/splqueue.inc71
-rw-r--r--ext/spl/internal/splstack.inc48
-rw-r--r--ext/spl/php_spl.c32
-rw-r--r--ext/spl/php_spl.h11
-rwxr-xr-xext/spl/spl.php1160
-rw-r--r--ext/spl/spl_array.c353
-rw-r--r--ext/spl/spl_array.h11
-rw-r--r--ext/spl/spl_directory.c263
-rw-r--r--ext/spl/spl_directory.h13
-rw-r--r--ext/spl/spl_dllist.c128
-rw-r--r--ext/spl/spl_dllist.h11
-rw-r--r--ext/spl/spl_engine.c11
-rw-r--r--ext/spl/spl_engine.h11
-rw-r--r--ext/spl/spl_exceptions.c11
-rw-r--r--ext/spl/spl_exceptions.h11
-rw-r--r--ext/spl/spl_fixedarray.c79
-rw-r--r--ext/spl/spl_fixedarray.h11
-rw-r--r--ext/spl/spl_functions.c24
-rw-r--r--ext/spl/spl_functions.h11
-rw-r--r--ext/spl/spl_heap.c396
-rw-r--r--ext/spl/spl_heap.h11
-rw-r--r--ext/spl/spl_iterators.c305
-rw-r--r--ext/spl/spl_iterators.h17
-rw-r--r--ext/spl/spl_observer.c173
-rw-r--r--ext/spl/spl_observer.h11
-rw-r--r--ext/spl/tests/ArrayObject_get_object_vars.phpt30
-rw-r--r--ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt23
-rw-r--r--ext/spl/tests/DirectoryIterator_getExtension_basic.phpt27
-rw-r--r--ext/spl/tests/DirectoryIterator_getGroup_basic.phpt3
-rw-r--r--ext/spl/tests/DirectoryIterator_getInode_basic.phpt2
-rw-r--r--ext/spl/tests/DirectoryIterator_getInode_error.phpt2
-rw-r--r--ext/spl/tests/DirectoryIterator_getOwner_basic.phpt3
-rw-r--r--ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt26
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_add_missing_parameter1.phpt10
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_add_missing_parameter2.phpt10
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_bottom_pass_array.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_bottom_pass_float.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_bottom_pass_integer.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_bottom_pass_null.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_count.phpt12
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_count_param_SplDoublyLinkedList.phpt11
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_getIteratorMode_error.phpt11
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_isEmpty_empty-with-parameter.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty-with-parameter.phpt20
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetExists_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetGet_empty.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetGet_missing_param.phpt15
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetSet_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_offsetSet_one_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_pop_noParams.phpt15
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_pop_params.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_push_missing_parameter.phpt12
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_serialization.phpt4
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_setIteratorMode_param_SplDoublyLinkedList.phpt11
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_top_pass_array.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_top_pass_float.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_top_pass_integer.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_top_pass_null.phpt14
-rw-r--r--ext/spl/tests/SplDoublyLinkedList_unshift_missing_parameter.phpt12
-rw-r--r--ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt2
-rw-r--r--ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt2
-rw-r--r--ext/spl/tests/SplFileInfo_getGroup_error.phpt4
-rw-r--r--ext/spl/tests/SplFileInfo_getInode_error.phpt4
-rw-r--r--ext/spl/tests/SplFileInfo_getOwner_error.phpt4
-rw-r--r--ext/spl/tests/SplFileInfo_getPerms_error.phpt4
-rw-r--r--ext/spl/tests/SplFileObject_current_error001.phpt19
-rw-r--r--ext/spl/tests/SplFileObject_fflush_basic_001.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_escape_empty.phpt31
-rw-r--r--ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fpassthru_basic.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_error.phpt36
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation1.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation10.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation11.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation12.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation13.phpt4
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation14.phpt4
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation15.phpt22
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation5.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation6.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation7.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fputcsv_variation8.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fscanf_basic.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_fseek_error_001.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_fwrite_error_001.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_fwrite_variation_001.phpt4
-rw-r--r--ext/spl/tests/SplFileObject_fwrite_variation_002.phpt4
-rw-r--r--ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt2
-rw-r--r--ext/spl/tests/SplFileObject_getchildren_error001.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_getflags_error002.phpt21
-rw-r--r--ext/spl/tests/SplFileObject_haschildren_error001.phpt12
-rw-r--r--ext/spl/tests/SplFileObject_key_error003.phpt15
-rw-r--r--ext/spl/tests/SplFileObject_rewind_error001.phpt22
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_basic.phpt6
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_error001.phpt6
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_error002.phpt6
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_error003.phpt8
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt6
-rw-r--r--ext/spl/tests/SplFileObject_setCsvControl_variation002.phpt19
-rw-r--r--ext/spl/tests/SplFixedArray_count_checkParams.phpt15
-rw-r--r--ext/spl/tests/SplFixedArray_count_param_int.phpt11
-rw-r--r--ext/spl/tests/SplFixedArray_current_param.phpt24
-rw-r--r--ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_001.phpt10
-rw-r--r--ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_002.phpt10
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_indexes.phpt2
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt2
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_param_boolean.phpt10
-rw-r--r--ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt2
-rw-r--r--ext/spl/tests/SplFixedArray_getSize_pass_param.phpt12
-rw-r--r--ext/spl/tests/SplFixedArray_key_param.phpt24
-rw-r--r--ext/spl/tests/SplFixedArray_next_param.phpt18
-rw-r--r--ext/spl/tests/SplFixedArray_offsetExists_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplFixedArray_offsetGet_invalid_parameter.phpt16
-rw-r--r--ext/spl/tests/SplFixedArray_offsetSet_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplFixedArray_offsetSet_one_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplFixedArray_offsetUnset_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplFixedArray_offsetUnset_string.phpt2
-rw-r--r--ext/spl/tests/SplFixedArray_rewind_param.phpt18
-rw-r--r--ext/spl/tests/SplFixedArray_setSize_param_array.phpt18
-rw-r--r--ext/spl/tests/SplFixedArray_setsize_001.phpt2
-rw-r--r--ext/spl/tests/SplFixedArray_toArray_with-params.phpt19
-rw-r--r--ext/spl/tests/SplHeap_count_invalid_parameter.phpt46
-rw-r--r--ext/spl/tests/SplHeap_extract_invalid_parameter.phpt46
-rw-r--r--ext/spl/tests/SplHeap_insert_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplHeap_isEmpty_invalid_parameter.phpt46
-rw-r--r--ext/spl/tests/SplObjectStorage_addAll_invalid_parameter.phpt42
-rw-r--r--ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt19
-rw-r--r--ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt42
-rw-r--r--ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt42
-rw-r--r--ext/spl/tests/SplObjectStorage_offsetGet_invalid_parameter.phpt44
-rw-r--r--ext/spl/tests/SplObjectStorage_removeAllExcept_invalid_parameter.phpt43
-rw-r--r--ext/spl/tests/SplObjectStorage_removeAll_invalid_parameter.phpt42
-rw-r--r--ext/spl/tests/SplObjectStorage_setInfo_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt26
-rw-r--r--ext/spl/tests/SplObjectStorage_unserialize_nested.phpt2
-rw-r--r--ext/spl/tests/SplPriorityQueue_extract_invalid_parameter.phpt46
-rw-r--r--ext/spl/tests/SplPriorityQueue_insert_invalid_parameter.phpt15
-rw-r--r--ext/spl/tests/SplPriorityQueue_setExtractFlags_zero.phpt15
-rw-r--r--ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt12
-rw-r--r--ext/spl/tests/arrayObject_magicMethods5.phpt8
-rw-r--r--ext/spl/tests/array_013.phpt2
-rw-r--r--ext/spl/tests/array_017.phpt72
-rw-r--r--ext/spl/tests/array_025.phpt2
-rw-r--r--ext/spl/tests/array_026.phpt6
-rw-r--r--ext/spl/tests/bug38618.phpt2
-rw-r--r--ext/spl/tests/bug42364.phpt11
-rw-r--r--ext/spl/tests/bug45216.phpt4
-rw-r--r--ext/spl/tests/bug45826.phpt42
-rw-r--r--ext/spl/tests/bug47534.phpt4
-rw-r--r--ext/spl/tests/bug49263.phpt2
-rw-r--r--ext/spl/tests/bug53071.phpt2
-rw-r--r--ext/spl/tests/bug61347.phpt4
-rw-r--r--ext/spl/tests/bug62978.phpt2
-rw-r--r--ext/spl/tests/bug67359.phpt2
-rw-r--r--ext/spl/tests/bug68825.phpt12
-rw-r--r--ext/spl/tests/bug70868.phpt2
-rw-r--r--ext/spl/tests/bug71412.phpt2
-rw-r--r--ext/spl/tests/bug73423.phpt14
-rw-r--r--ext/spl/tests/bug74669.phpt2
-rw-r--r--ext/spl/tests/bug78409.phpt26
-rw-r--r--ext/spl/tests/bug78436.phpt46
-rw-r--r--ext/spl/tests/bug78456.phpt23
-rw-r--r--ext/spl/tests/class_implements_variation2.phpt259
-rw-r--r--ext/spl/tests/class_uses_variation2.phpt261
-rw-r--r--ext/spl/tests/countable_class_basic1.phpt2
-rw-r--r--ext/spl/tests/dit_005.phpt3
-rw-r--r--ext/spl/tests/dualiterator.inc (renamed from ext/spl/examples/dualiterator.inc)0
-rw-r--r--ext/spl/tests/dualiterator_001.phpt (renamed from ext/spl/examples/tests/dualiterator_001.phpt)2
-rw-r--r--ext/spl/tests/fileobject_001.phpt10
-rw-r--r--[-rwxr-xr-x]ext/spl/tests/fileobject_001a.txt0
-rw-r--r--[-rwxr-xr-x]ext/spl/tests/fileobject_001b.txt0
-rw-r--r--ext/spl/tests/fileobject_002.phpt6
-rw-r--r--ext/spl/tests/fileobject_003.phpt6
-rw-r--r--ext/spl/tests/fileobject_004.phpt2
-rw-r--r--ext/spl/tests/fileobject_005.phpt6
-rw-r--r--ext/spl/tests/fileobject_getmaxlinelen_error001.phpt14
-rw-r--r--ext/spl/tests/fileobject_setmaxlinelen_error002.phpt12
-rw-r--r--ext/spl/tests/fileobject_setmaxlinelen_error003.phpt12
-rw-r--r--ext/spl/tests/heap_isempty_variation_001.phpt16
-rw-r--r--ext/spl/tests/heap_top_variation_001.phpt14
-rw-r--r--ext/spl/tests/iterator_035.phpt2
-rw-r--r--ext/spl/tests/iterator_036.phpt7
-rw-r--r--ext/spl/tests/limititerator_seek.phpt16
-rw-r--r--ext/spl/tests/observer_010.phpt3
-rw-r--r--ext/spl/tests/pqueue_compare_error.phpt18
-rw-r--r--ext/spl/tests/recursive_tree_iterator_007.phpt6
-rw-r--r--ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt32
-rw-r--r--ext/spl/tests/recursivecomparedualiterator.inc (renamed from ext/spl/examples/recursivecomparedualiterator.inc)0
-rw-r--r--ext/spl/tests/recursivedualiterator.inc (renamed from ext/spl/examples/recursivedualiterator.inc)0
-rw-r--r--ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt14
-rw-r--r--ext/spl/tests/regexiterator_setflags_exception.phpt35
-rw-r--r--ext/spl/tests/regexiterator_setpregflags_exception.phpt36
-rw-r--r--ext/spl/tests/splDoublyLinkedList_shift_noParams.phpt15
-rw-r--r--ext/spl/tests/spl_005.phpt21
-rw-r--r--ext/spl/tests/spl_autoload_007.phpt2
-rw-r--r--ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt16
-rw-r--r--ext/spl/tests/spl_heap_count_error.phpt12
-rw-r--r--ext/spl/tests/spl_heap_extract_parameter_error.phpt27
-rw-r--r--ext/spl/tests/spl_heap_insert_basic.phpt20
-rw-r--r--ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt13
-rw-r--r--ext/spl/tests/spl_iterator_to_array_basic.phpt13
-rw-r--r--ext/spl/tests/spl_maxheap_compare_basic.phpt22
-rw-r--r--ext/spl/tests/spl_minheap_compare_error.phpt30
-rw-r--r--ext/spl/tests/spl_pq_top_error_args.phpt12
-rw-r--r--ext/spl/tests/spl_pqueue_gc.phpt15
-rw-r--r--ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt31
-rw-r--r--ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt28
-rw-r--r--ext/spl/tests/splpriorityqueue_extract.phpt17
-rw-r--r--ext/spl/tests/splpriorityqueue_setextractflags.phpt15
-rw-r--r--[-rwxr-xr-x]ext/spl/tests/testclass0
-rw-r--r--ext/spl/tests/unserialize_errors.phpt138
264 files changed, 1561 insertions, 9180 deletions
diff --git a/ext/spl/CREDITS b/ext/spl/CREDITS
index b1bef82832..b1bef82832 100755..100644
--- a/ext/spl/CREDITS
+++ b/ext/spl/CREDITS
diff --git a/ext/spl/README b/ext/spl/README
deleted file mode 100755
index 0f0e1e31b0..0000000000
--- a/ext/spl/README
+++ /dev/null
@@ -1,7 +0,0 @@
-This is an extension that aims to implement some efficient data access
-interfaces and classes. You'll find the classes documented using php
-code in the file spl.php or in the corresponding .inc file in the examples
-subdirectory. Based on the internal implementations or the files in the
-examples subdirectory there are also some .php files to experiment with.
-
-For more information look at: http://php.net/manual/en/book.spl.php
diff --git a/ext/spl/config.m4 b/ext/spl/config.m4
index 4ad29f3c94..8e0d31f3e2 100755..100644
--- a/ext/spl/config.m4
+++ b/ext/spl/config.m4
@@ -1,6 +1,3 @@
-dnl config.m4 for extension SPL
-
- 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,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
- 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_ADD_EXTENSION_DEP(spl, pcre, true)
+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,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1)
+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_ADD_EXTENSION_DEP(spl, pcre, true)
diff --git a/ext/spl/config.w32 b/ext/spl/config.w32
index b82333a261..8d8277be23 100644
--- a/ext/spl/config.w32
+++ b/ext/spl/config.w32
@@ -1,6 +1,5 @@
// 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 */, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1");
-AC_DEFINE('HAVE_SPL', 1);
PHP_SPL="yes";
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");
diff --git a/ext/spl/doxygen.cfg b/ext/spl/doxygen.cfg
deleted file mode 100755
index 5c7025a9ad..0000000000
--- a/ext/spl/doxygen.cfg
+++ /dev/null
@@ -1,217 +0,0 @@
-# Doxyfile 1.3.9.1
-
-#---------------------------------------------------------------------------
-# Project related configuration options
-#---------------------------------------------------------------------------
-PROJECT_NAME = SPL-StandardPHPLibrary
-PROJECT_NUMBER =
-OUTPUT_DIRECTORY =
-CREATE_SUBDIRS = NO
-OUTPUT_LANGUAGE = English
-USE_WINDOWS_ENCODING = YES
-BRIEF_MEMBER_DESC = NO
-REPEAT_BRIEF = YES
-ABBREVIATE_BRIEF =
-ALWAYS_DETAILED_SEC = YES
-INLINE_INHERITED_MEMB = YES
-FULL_PATH_NAMES = NO
-STRIP_FROM_PATH =
-STRIP_FROM_INC_PATH =
-SHORT_NAMES = NO
-JAVADOC_AUTOBRIEF = YES
-MULTILINE_CPP_IS_BRIEF = YES
-DETAILS_AT_TOP = NO
-INHERIT_DOCS = YES
-DISTRIBUTE_GROUP_DOC = YES
-TAB_SIZE = 4
-ALIASES =
-OPTIMIZE_OUTPUT_FOR_C = NO
-OPTIMIZE_OUTPUT_JAVA = NO
-SUBGROUPING = YES
-#---------------------------------------------------------------------------
-# Build related configuration options
-#---------------------------------------------------------------------------
-EXTRACT_ALL = YES
-EXTRACT_PRIVATE = YES
-EXTRACT_STATIC = YES
-EXTRACT_LOCAL_CLASSES = YES
-EXTRACT_LOCAL_METHODS = YES
-HIDE_UNDOC_MEMBERS = NO
-HIDE_UNDOC_CLASSES = NO
-HIDE_FRIEND_COMPOUNDS = NO
-HIDE_IN_BODY_DOCS = NO
-INTERNAL_DOCS = YES
-CASE_SENSE_NAMES = YES
-HIDE_SCOPE_NAMES = NO
-SHOW_INCLUDE_FILES = YES
-INLINE_INFO = YES
-SORT_MEMBER_DOCS = YES
-SORT_BRIEF_DOCS = YES
-SORT_BY_SCOPE_NAME = NO
-GENERATE_TODOLIST = YES
-GENERATE_TESTLIST = YES
-GENERATE_BUGLIST = YES
-GENERATE_DEPRECATEDLIST= YES
-ENABLED_SECTIONS =
-MAX_INITIALIZER_LINES = 30
-SHOW_USED_FILES = YES
-SHOW_DIRECTORIES = YES
-#---------------------------------------------------------------------------
-# configuration options related to warning and progress messages
-#---------------------------------------------------------------------------
-QUIET = NO
-WARNINGS = YES
-WARN_IF_UNDOCUMENTED = YES
-WARN_IF_DOC_ERROR = YES
-WARN_FORMAT = "$file:$line: $text"
-WARN_LOGFILE =
-#---------------------------------------------------------------------------
-# configuration options related to the input files
-#---------------------------------------------------------------------------
-INPUT = spl.php \
- examples \
- internal
-FILE_PATTERNS = *.inc \
- *.php
-RECURSIVE = NO
-EXCLUDE =
-EXCLUDE_SYMLINKS = NO
-EXCLUDE_PATTERNS =
-EXAMPLE_PATH =
-EXAMPLE_PATTERNS =
-EXAMPLE_RECURSIVE = NO
-IMAGE_PATH =
-INPUT_FILTER =
-FILTER_PATTERNS =
-FILTER_SOURCE_FILES = NO
-#---------------------------------------------------------------------------
-# configuration options related to source browsing
-#---------------------------------------------------------------------------
-SOURCE_BROWSER = YES
-INLINE_SOURCES = YES
-STRIP_CODE_COMMENTS = YES
-REFERENCED_BY_RELATION = YES
-REFERENCES_RELATION = YES
-VERBATIM_HEADERS = YES
-#---------------------------------------------------------------------------
-# configuration options related to the alphabetical class index
-#---------------------------------------------------------------------------
-ALPHABETICAL_INDEX = YES
-COLS_IN_ALPHA_INDEX = 4
-IGNORE_PREFIX =
-#---------------------------------------------------------------------------
-# configuration options related to the HTML output
-#---------------------------------------------------------------------------
-GENERATE_HTML = YES
-HTML_OUTPUT = html
-HTML_FILE_EXTENSION = .html
-HTML_HEADER =
-HTML_FOOTER =
-HTML_STYLESHEET =
-HTML_ALIGN_MEMBERS = YES
-GENERATE_HTMLHELP = YES
-CHM_FILE = ../spl.chm
-#HHC_LOCATION = hhc.exe
-GENERATE_CHI = NO
-BINARY_TOC = NO
-TOC_EXPAND = NO
-DISABLE_INDEX = NO
-ENUM_VALUES_PER_LINE = 1
-GENERATE_TREEVIEW = YES
-TREEVIEW_WIDTH = 250
-#---------------------------------------------------------------------------
-# configuration options related to the LaTeX output
-#---------------------------------------------------------------------------
-GENERATE_LATEX = NO
-LATEX_OUTPUT = latex
-LATEX_CMD_NAME = latex
-MAKEINDEX_CMD_NAME = makeindex
-COMPACT_LATEX = NO
-PAPER_TYPE = a4wide
-EXTRA_PACKAGES =
-LATEX_HEADER =
-PDF_HYPERLINKS = NO
-USE_PDFLATEX = NO
-LATEX_BATCHMODE = NO
-LATEX_HIDE_INDICES = NO
-#---------------------------------------------------------------------------
-# configuration options related to the RTF output
-#---------------------------------------------------------------------------
-GENERATE_RTF = NO
-RTF_OUTPUT = rtf
-COMPACT_RTF = NO
-RTF_HYPERLINKS = NO
-RTF_STYLESHEET_FILE =
-RTF_EXTENSIONS_FILE =
-#---------------------------------------------------------------------------
-# configuration options related to the man page output
-#---------------------------------------------------------------------------
-GENERATE_MAN = NO
-MAN_OUTPUT = man
-MAN_EXTENSION = .3
-MAN_LINKS = NO
-#---------------------------------------------------------------------------
-# configuration options related to the XML output
-#---------------------------------------------------------------------------
-GENERATE_XML = YES
-XML_OUTPUT = xml
-XML_SCHEMA =
-XML_DTD =
-XML_PROGRAMLISTING = YES
-#---------------------------------------------------------------------------
-# configuration options for the AutoGen Definitions output
-#---------------------------------------------------------------------------
-GENERATE_AUTOGEN_DEF = NO
-#---------------------------------------------------------------------------
-# configuration options related to the Perl module output
-#---------------------------------------------------------------------------
-GENERATE_PERLMOD = NO
-PERLMOD_LATEX = NO
-PERLMOD_PRETTY = YES
-PERLMOD_MAKEVAR_PREFIX =
-#---------------------------------------------------------------------------
-# Configuration options related to the preprocessor
-#---------------------------------------------------------------------------
-ENABLE_PREPROCESSING = YES
-MACRO_EXPANSION = NO
-EXPAND_ONLY_PREDEF = NO
-SEARCH_INCLUDES = YES
-INCLUDE_PATH =
-INCLUDE_FILE_PATTERNS =
-PREDEFINED =
-EXPAND_AS_DEFINED =
-SKIP_FUNCTION_MACROS = YES
-#---------------------------------------------------------------------------
-# Configuration::additions related to external references
-#---------------------------------------------------------------------------
-TAGFILES =
-GENERATE_TAGFILE =
-ALLEXTERNALS = NO
-EXTERNAL_GROUPS = YES
-PERL_PATH = /usr/bin/perl
-#---------------------------------------------------------------------------
-# Configuration options related to the dot tool
-#---------------------------------------------------------------------------
-CLASS_DIAGRAMS = YES
-HIDE_UNDOC_RELATIONS = YES
-HAVE_DOT = YES
-CLASS_GRAPH = YES
-COLLABORATION_GRAPH = YES
-UML_LOOK = YES
-TEMPLATE_RELATIONS = NO
-INCLUDE_GRAPH = YES
-INCLUDED_BY_GRAPH = YES
-CALL_GRAPH = YES
-GRAPHICAL_HIERARCHY = YES
-DOT_IMAGE_FORMAT = png
-DOT_PATH =
-DOTFILE_DIRS =
-MAX_DOT_GRAPH_WIDTH = 1200
-MAX_DOT_GRAPH_HEIGHT = 1024
-MAX_DOT_GRAPH_DEPTH = 0
-GENERATE_LEGEND = YES
-DOT_CLEANUP = NO
-#---------------------------------------------------------------------------
-# Configuration::additions related to the search engine
-#---------------------------------------------------------------------------
-SEARCHENGINE = NO
diff --git a/ext/spl/examples/autoload.inc b/ext/spl/examples/autoload.inc
deleted file mode 100644
index 0dc423199e..0000000000
--- a/ext/spl/examples/autoload.inc
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-
-/** @file autoload.inc
- * @ingroup Examples
- * @brief function __autoload
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** \internal
- * Tries to load class $classname from directory $dir.
- */
-function __load_class($classname, $dir)
-{
- $file = $dir . '/' . $classname . '.inc';
- if (file_exists($file))
- {
- require_once($file);
- return true;
- }
- return false;
-}
-
-/**
- * @brief Class loader for SPL example classes
- * @author Marcus Boerger
- * @version 1.0
- *
- * Loads classes automatically from include_path as given by ini or from
- * current directory of script or include file.
- */
-function __autoload($classname) {
- $classname = strtolower($classname);
- $inc = split(':', ini_get('include_path'));
- $inc[] = '.';
- $inc[] = dirname($_SERVER['PATH_TRANSLATED']);
- foreach($inc as $dir)
- {
- if (__load_class($classname, $dir))
- {
- fprintf(STDERR, 'Loading class('.$classname.")\n");
- return;
- }
- }
- fprintf(STDERR, 'Class not found ('.$classname.")\n");
-}
-
-?>
diff --git a/ext/spl/examples/cachingrecursiveiterator.inc b/ext/spl/examples/cachingrecursiveiterator.inc
deleted file mode 100644
index f0e060a0a7..0000000000
--- a/ext/spl/examples/cachingrecursiveiterator.inc
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-/** @file cachingrecursiveiterator.inc
- * @ingroup Examples
- * @brief class CachingRecursiveIterator
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief Compatibility to PHP 5.0
- * @author Marcus Boerger
- * @version 1.2
- * @deprecated
- *
- * Class RecursiveCachingIterator was named CachingRecursiveIterator until
- * PHP 5.0.6.
- *
- * @see RecursiveCachingIterator
- */
-
-class CachingRecursiveIterator extends RecursiveCachingIterator
-{
-}
-
-?>
diff --git a/ext/spl/examples/callbackfilteriterator.inc b/ext/spl/examples/callbackfilteriterator.inc
deleted file mode 100644
index 4d49a52807..0000000000
--- a/ext/spl/examples/callbackfilteriterator.inc
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-
-/** @file callbackfilteriterator.inc
- * @ingroup Examples
- * @brief class CallbackFilterIterator
- * @author Marcus Boerger
- * @author Kevin McArthur
- * @date 2006 - 2006
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief A non abstract FiletrIterator that uses a callback foreach element
- * @author Marcus Boerger
- * @author Kevin McArthur
- * @version 1.0
- */
-class CallbackFilterIterator extends FilterIterator
-{
- const USE_FALSE = 0; /**< mode: accept no elements, no callback */
- const USE_TRUE = 1; /**< mode: accept all elements, no callback */
- const USE_VALUE = 2; /**< mode: pass value to callback */
- const USE_KEY = 3; /**< mode: pass key to callback */
- const USE_BOTH = 4; /**< mode: pass value and key to callback */
-
- const REPLACE = 0x00000001; /**< flag: pass key/value by reference */
-
- private $callback; /**< callback to use */
- private $mode; /**< mode any of USE_VALUE, USE_KEY, USE_BOTH */
- private $flags; /**< flags (REPLACE) */
- private $key; /**< key value */
- private $current; /**< current value */
-
- /** Construct a CallbackFilterIterator
- *
- * @param it inner iterator (iterator to filter)
- * @param callback callback function
- * @param mode any of USE_VALUE, USE_KEY, USE_BOTH
- * @param flags any of 0, REPLACE
- */
- public function __construct(Iterator $it, $callback, $mode = self::USE_VALUE, $flags = 0)
- {
- parent::__construct($it);
- $this->callback = $callback;
- $this->mode = $mode;
- $this->flags = $flags;
- }
-
- /** Call the filter callback
- * @return result of filter callback
- */
- public function accept()
- {
- $this->key = parent::key();
- $this->current = parent::current();
-
- switch($this->mode) {
- default:
- case self::USE_FALSE;
- return false;
- case self::USE_TRUE:
- return true;
- case self::USE_VALUE:
- if($this->flags & self::REPLACE) {
- return (bool) call_user_func($this->callback, &$this->current);
- } else {
- return (bool) call_user_func($this->callback, $this->current);
- }
- case self::USE_KEY:
- if($this->flags & self::REPLACE) {
- return (bool) call_user_func($this->callback, &$this->key);
- } else {
- return (bool) call_user_func($this->callback, $this->key);
- }
- case SELF::USE_BOTH:
- if($this->flags & self::REPLACE) {
- return (bool) call_user_func($this->callback, &$this->key, &$this->current);
- } else {
- return (bool) call_user_func($this->callback, $this->key, $this->current);
- }
- }
- }
-
- /** @return current key value */
- function key()
- {
- return $this->key;
- }
-
- /** @return current value */
- function current()
- {
- return $this->current;
- }
-
- /** @return operation mode */
- function getMode()
- {
- return $this->mode;
- }
-
- /** @param $mode set new mode, @see mode */
- function setMode($mode)
- {
- $this->mode = $mode;
- }
-
- /** @return operation flags */
- function getFlags()
- {
- return $this->flags;
- }
-
- /** @param $flags set new flags, @see flags */
- function setFlags($flags)
- {
- $this->flags = $flags;
- }
-}
-
-?>
diff --git a/ext/spl/examples/class_tree.php b/ext/spl/examples/class_tree.php
deleted file mode 100755
index a5d2d7b1ca..0000000000
--- a/ext/spl/examples/class_tree.php
+++ /dev/null
@@ -1,113 +0,0 @@
-<?php
-
-/** @file class_tree.php
- * @brief Class Tree example
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2008
- * @version 1.1
- *
- * Usage: php class_tree.php \<class\>
- *
- * Simply specify the root class or interface to tree with parameter \<class\>.
- */
-
-if ($argc < 2) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <class>
-
-Displays a graphical tree for the given <class>.
-
-<class> The class or interface for which to generate the tree graph.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("RecursiveTreeIterator", false)) require_once("recursivetreeiterator.inc");
-
-/** \brief Collects sub classes for given class or interface
- */
-class SubClasses extends RecursiveArrayIterator
-{
- /** @param base base class to collect sub classes for
- * @param check_interfaces whether we deal with interfaces
- */
- function __construct($base, $check_interfaces = false)
- {
- foreach(get_declared_classes() as $cname)
- {
- $parent = get_parent_class($cname);
- if (strcasecmp($parent, $base) == 0)
- {
- $this->offsetSet($cname, new SubClasses($cname));
- }
- if ($check_interfaces)
- {
- if ($parent)
- {
- $parent_imp = class_implements($parent);
- }
- foreach(class_implements($cname) as $iname)
- {
- if (strcasecmp($iname, $base) == 0)
- {
- if (!$parent || !in_array($iname, $parent_imp))
- {
- $this->offsetSet($cname, new SubClasses($cname));
- }
- }
- }
- }
- }
- if ($check_interfaces)
- {
- foreach(get_declared_interfaces() as $cname)
- {
- foreach(class_implements($cname) as $iname)
- {
- if (strcasecmp($iname, $base) == 0)
- {
- $this->offsetSet($cname, new SubClasses($cname, true));
- }
- }
- }
- }
- $this->uksort('strnatcasecmp');
- }
-
- /** @return key() since that is the name we need
- */
- function current()
- {
- $result = parent::key();
- $parent = get_parent_class($result);
- if ($parent)
- {
- $interfaces = array_diff(class_implements($result), class_implements($parent));
- if ($interfaces)
- {
- $implements = array();
- foreach($interfaces as $interface)
- {
- $implements = array_merge($implements, class_implements($interface));
- }
- $interfaces = array_diff($interfaces, $implements);
- natcasesort($interfaces);
- $result .= ' (' . join(', ', $interfaces) . ')';
- }
- }
- return $result;
- }
-}
-
-$it = new RecursiveTreeIterator(new SubClasses($argv[1], true));
-
-echo $argv[1]."\n";
-foreach($it as $c=>$v)
-{
- echo "$v\n";
-}
-
-?>
diff --git a/ext/spl/examples/dba_array.php b/ext/spl/examples/dba_array.php
deleted file mode 100755
index 7930348f7c..0000000000
--- a/ext/spl/examples/dba_array.php
+++ /dev/null
@@ -1,52 +0,0 @@
-<?php
-
-/** @file dba_array.php
- * @brief Program DBA array utility
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage php dba_array.php \<file\> \<handler\> \<key\> [\<value\>]
- *
- * If \<value\> is specified then \<key\> is set to \<value\> in \<file\>.
- * Else the value of \<key\> is printed only.
- *
- * Note: configure with --enable-dba
- */
-
-if ($argc < 4) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <file> <handler> <key> [<value>]
-
-If <value> is specified then <key> is set to <value> in <file>.
-Else the value of <key> is printed only.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
-
-try {
- if ($argc > 2) {
- $dba = new DbaArray($argv[1], $argv[2]);
- if ($dba && $argc > 3) {
- if ($argc > 4) {
- $dba[$argv[3]] = $argv[4];
- }
- var_dump(array('Index' => $argv[3], 'Value' => $dba[$argv[3]]));
- }
- unset($dba);
- }
- else
- {
- echo "Not enough parameters\n";
- exit(1);
- }
-}
-catch (exception $err) {
- var_dump($err);
- exit(1);
-}
-?>
diff --git a/ext/spl/examples/dba_dump.php b/ext/spl/examples/dba_dump.php
deleted file mode 100755
index 4c080729b2..0000000000
--- a/ext/spl/examples/dba_dump.php
+++ /dev/null
@@ -1,42 +0,0 @@
-<?php
-
-/** @file dba_dump.php
- * @brief Program DBA dump utility
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage: php dba_dump.php \<file\> \<handler\> [\<regex\>]
- *
- * Show all groups in the ini file specified by \<file\>.
- * The regular expression \<regex\> is used to filter the by setting name.
- *
- * Note: configure with --enable-dba
- */
-
-if ($argc < 3) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <file> <handler> [<regex>]
-
-Show all groups in the ini file specified by <file>.
-The regular expression <regex> is used to filter the by setting name.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
-if (!class_exists("KeyFilter", false)) require_once("keyfilter.inc");
-
-$db = new DbaReader($argv[1], $argv[2]);
-
-if ($argc>3) {
- $db = new KeyFilter($db, $argv[3]);
-}
-
-foreach($db as $key => $val) {
- echo "'$key' => '$val'\n";
-}
-
-?>
diff --git a/ext/spl/examples/dbaarray.inc b/ext/spl/examples/dbaarray.inc
deleted file mode 100644
index d6ee56f442..0000000000
--- a/ext/spl/examples/dbaarray.inc
+++ /dev/null
@@ -1,95 +0,0 @@
-<?php
-
-/** @file dbaarray.inc
- * @ingroup Examples
- * @brief class DbaArray
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
-
-/** @ingroup Examples
- * @brief This implements a DBA Array
- * @author Marcus Boerger
- * @version 1.0
- */
-class DbaArray extends DbaReader implements ArrayAccess
-{
-
- /**
- * Open database $file with $handler in read only mode.
- *
- * @param file Database file to open.
- * @param handler Handler to use for database access.
- */
- function __construct($file, $handler)
- {
- $this->db = dba_popen($file, "c", $handler);
- if (!$this->db) {
- throw new exception("Databse could not be opened");
- }
- }
-
- /**
- * Close database.
- */
- function __destruct()
- {
- parent::__destruct();
- }
-
- /**
- * Read an entry.
- *
- * @param $name key to read from
- * @return value associated with $name
- */
- function offsetGet($name)
- {
- $data = dba_fetch($name, $this->db);
- if($data) {
- //return unserialize($data);
- return $data;
- }
- else
- {
- return NULL;
- }
- }
-
- /**
- * Set an entry.
- *
- * @param $name key to write to
- * @param $value value to write
- */
- function offsetSet($name, $value)
- {
- //dba_replace($name, serialize($value), $this->db);
- dba_replace($name, $value, $this->db);
- return $value;
- }
-
- /**
- * @return whether key $name exists.
- */
- function offsetExists($name)
- {
- return dba_exists($name, $this->db);
- }
-
- /**
- * Delete a key/value pair.
- *
- * @param $name key to delete.
- */
- function offsetUnset($name)
- {
- return dba_delete($name, $this->db);
- }
-}
-
-?>
diff --git a/ext/spl/examples/dbareader.inc b/ext/spl/examples/dbareader.inc
deleted file mode 100644
index 095c5c29d5..0000000000
--- a/ext/spl/examples/dbareader.inc
+++ /dev/null
@@ -1,96 +0,0 @@
-<?php
-
-/** @file dbareader.inc
- * @ingroup Examples
- * @brief class DbaReader
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief This implements a DBA Iterator.
- * @author Marcus Boerger
- * @version 1.0
- */
-class DbaReader implements Iterator
-{
-
- protected $db = NULL;
- private $key = false;
- private $val = false;
-
- /**
- * Open database $file with $handler in read only mode.
- *
- * @param file Database file to open.
- * @param handler Handler to use for database access.
- */
- function __construct($file, $handler) {
- if (!$this->db = dba_open($file, 'r', $handler)) {
- throw new exception('Could not open file ' . $file);
- }
- }
-
- /**
- * Close database.
- */
- function __destruct() {
- dba_close($this->db);
- }
-
- /**
- * Rewind to first element.
- */
- function rewind() {
- $this->key = dba_firstkey($this->db);
- $this->fetch_data();
- }
-
- /**
- * Move to next element.
- *
- * @return void
- */
- function next() {
- $this->key = dba_nextkey($this->db);
- $this->fetch_data();
- }
-
- /**
- * Fetches the current data if $key is valid
- */
- private function fetch_data() {
- if ($this->key !== false) {
- $this->val = dba_fetch($this->key, $this->db);
- }
- }
-
- /**
- * @return Current data.
- */
- function current() {
- return $this->val;
- }
-
- /**
- * @return Whether more elements are available.
- */
- function valid() {
- if ($this->db && $this->key !== false) {
- return true;
- } else {
- return false;
- }
- }
-
- /**
- * @return Current key.
- */
- function key() {
- return $this->key;
- }
-}
-
-?>
diff --git a/ext/spl/examples/directoryfilterdots.inc b/ext/spl/examples/directoryfilterdots.inc
deleted file mode 100644
index 454bd90883..0000000000
--- a/ext/spl/examples/directoryfilterdots.inc
+++ /dev/null
@@ -1,45 +0,0 @@
-<?php
-
-/** @file directoryfilterdots.inc
- * @ingroup Examples
- * @brief class DirectoryFilterDots
- * @author Marcus Boerger
- * @date 2003 - 2006
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief A filtered DirectoryIterator
- * @author Marcus Boerger
- * @version 1.2
- *
- * This Iterator takes a pathname from which it creates a RecursiveDirectoryIterator
- * and makes it recursive. Further more it filters the entries '.' and '..'.
- */
-class DirectoryFilterDots extends RecursiveFilterIterator
-{
- /** Construct from a path.
- * @param $path directory to iterate
- */
- function __construct($path)
- {
- parent::__construct(new RecursiveDirectoryIterator($path));
- }
-
- /** @return whether the current entry is neither '.' nor '..'
- */
- function accept()
- {
- return !$this->getInnerIterator()->isDot();
- }
-
- /** @return the current entries path name
- */
- function key()
- {
- return $this->getInnerIterator()->getPathname();
- }
-}
-
-?>
diff --git a/ext/spl/examples/directorygraphiterator.inc b/ext/spl/examples/directorygraphiterator.inc
deleted file mode 100644
index 65a4dd7a38..0000000000
--- a/ext/spl/examples/directorygraphiterator.inc
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-
-/** @file directorygraphiterator.inc
- * @ingroup Examples
- * @brief class DirectoryGraphIterator
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief A tree iterator that only shows directories.
- * @author Marcus Boerger
- * @version 1.1
- */
-class DirectoryGraphIterator extends DirectoryTreeIterator
-{
- function __construct($path)
- {
- RecursiveIteratorIterator::__construct(
- new RecursiveCachingIterator(
- new ParentIterator(
- new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
- )
- ),
- CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
- ),
- parent::SELF_FIRST
- );
- }
-}
-
-?>
diff --git a/ext/spl/examples/directorytree.inc b/ext/spl/examples/directorytree.inc
deleted file mode 100644
index 20a15c815f..0000000000
--- a/ext/spl/examples/directorytree.inc
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-/** @file directorytree.inc
- * @ingroup Examples
- * @brief class DirectoryTree
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief A directory iterator that does not show '.' and '..'.
- * @author Marcus Boerger
- * @version 1.0
- */
-class DirectoryTree extends RecursiveIteratorIterator
-{
- /** Construct from a path.
- * @param $path directory to iterate
- */
- function __construct($path) {
- parent::__construct(new DirectoryFilterDots($path));
- }
-}
-
-?>
diff --git a/ext/spl/examples/directorytree.php b/ext/spl/examples/directorytree.php
deleted file mode 100755
index 38759837f5..0000000000
--- a/ext/spl/examples/directorytree.php
+++ /dev/null
@@ -1,37 +0,0 @@
-<?php
-
-/** @file directorytree.php
- * @brief Program Directory tree example
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage: php directorytree.php \<path\> [\<start\> [\<count\>]]
- *
- * Simply specify the path to tree with parameter \<path\>.
- */
-
-if ($argc < 2) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <path>
-
-Displays a graphical directory tree for the given <path>.
-
-<path> The directory for which to generate the directory tree graph.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
-
-$length = $argc > 3 ? $argv[3] : -1;
-
-echo $argv[1]."\n";
-foreach(new LimitIterator(new DirectoryTreeIterator($argv[1]), @$argv[2], $length) as $key=>$file) {
-//foreach(new DirectoryTreeIterator($argv[1]) as $file) {
- echo $file . "\n";
-}
-
-?>
diff --git a/ext/spl/examples/directorytreeiterator.inc b/ext/spl/examples/directorytreeiterator.inc
deleted file mode 100644
index 52a4e114ed..0000000000
--- a/ext/spl/examples/directorytreeiterator.inc
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-/** @file directorytreeiterator.inc
- * @ingroup Examples
- * @brief class DirectoryTreeIterator
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief DirectoryIterator to generate ASCII graphic directory trees
- * @author Marcus Boerger
- * @version 1.1
- */
-class DirectoryTreeIterator extends RecursiveIteratorIterator
-{
- /** Construct from a path.
- * @param $path directory to iterate
- */
- function __construct($path)
- {
- parent::__construct(
- new RecursiveCachingIterator(
- new RecursiveDirectoryIterator($path, RecursiveDirectoryIterator::KEY_AS_FILENAME
- ),
- CachingIterator::CALL_TOSTRING|CachingIterator::CATCH_GET_CHILD
- ),
- parent::SELF_FIRST
- );
- }
-
- /** @return the current element prefixed with ASCII graphics
- */
- function current()
- {
- $tree = '';
- for ($l=0; $l < $this->getDepth(); $l++) {
- $tree .= $this->getSubIterator($l)->hasNext() ? '| ' : ' ';
- }
- return $tree . ($this->getSubIterator($l)->hasNext() ? '|-' : '\-')
- . $this->getSubIterator($l)->__toString();
- }
-
- /** Aggregates the inner iterator
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->getSubIterator(), $func), $params);
- }
-}
-
-?>
diff --git a/ext/spl/examples/findfile.inc b/ext/spl/examples/findfile.inc
deleted file mode 100644
index afafa8124d..0000000000
--- a/ext/spl/examples/findfile.inc
+++ /dev/null
@@ -1,65 +0,0 @@
-<?php
-
-/** @file findfile.inc
- * @ingroup Examples
- * @brief class FindFile
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-if (!class_exists("FindFile", false)) require_once("findfile.inc");
-if (!class_exists("AppendIterator", false)) require_once("appenditerator.inc");
-
-/** @ingroup Examples
- * @brief Base class to find files
- * @author Marcus Boerger
- * @version 1.1
- *
- */
-class FindFile extends FilterIterator
-{
- /** @internal filename to find */
- private $file;
-
- /** Construct from path and filename
- *
- * @param $path the directory to search in
- * If path contains ';' then this parameter is split and every
- * part of it is used as separate directory.
- * @param $file the name of the files to search fro
- */
- function __construct($path, $file)
- {
- $this->file = $file;
- $list = split(PATH_SEPARATOR, $path);
- if (count($list) <= 1) {
- parent::__construct(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
- } else {
- $it = new AppendIterator();
- foreach($list as $path) {
- $it->append(new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path)));
- }
- parent::__construct($it);
- }
- }
-
- /** @return whether the current file matches the given filename
- */
- function accept()
- {
- return !strcmp($this->current(), $this->file);
- }
-
- /** @return the filename to search for.
- * @note This may be overloaded and contain a regular expression for an
- * extended class that uses regular expressions to search.
- */
- function getSearch()
- {
- return $this->file;
- }
-}
-
-?>
diff --git a/ext/spl/examples/findfile.php b/ext/spl/examples/findfile.php
deleted file mode 100755
index 7a850feddb..0000000000
--- a/ext/spl/examples/findfile.php
+++ /dev/null
@@ -1,33 +0,0 @@
-<?php
-
-/** @file findfile.php
- * @brief Program Find a specific file by name.
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage: php findfile.php \<path\> \<name\>
- *
- * \<path\> Path to search in. You can specify multiple paths by separating
- * them with ';'.
- * \<name\> Filename to look for.
- */
-
-if ($argc < 3) {
- echo <<<EOF
-Usage: php findfile.php <path> <name>
-
-Find a specific file by name.
-
-<path> Path to search in.
-<name> Filename to look for.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("FindFile", false)) require_once("findfile.inc");
-
-foreach(new FindFile($argv[1], $argv[2]) as $file) echo $file->getPathname()."\n";
-?>
diff --git a/ext/spl/examples/findregex.php b/ext/spl/examples/findregex.php
deleted file mode 100755
index 284f985943..0000000000
--- a/ext/spl/examples/findregex.php
+++ /dev/null
@@ -1,36 +0,0 @@
-<?php
-
-/** @file findregex.php
- * @brief Program Find a specific file by name.
- * @ingroup Examples
- * @author Marcus Boerger, Adam Trachtenberg
- * @date 2004
- *
- * Usage: php findregex.php \<path\> \<name\>
- *
- * \<path\> Path to search in.
- * \<name\> Filename to look for.
- */
-
-if ($argc < 3) {
- echo <<<EOF
-Usage: php findregex.php <file> <name>
-
-Find a specific file by name.
-
-<path> Path to search in.
-<name> Regex for filenames to look for.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("RegexFindFile", false)) require_once("regexfindfile.inc");
-
-foreach(new RegexFindFile($argv[1], $argv[2]) as $file)
-{
- echo $file->getPathname()."\n";
-}
-
-?>
diff --git a/ext/spl/examples/ini_groups.php b/ext/spl/examples/ini_groups.php
deleted file mode 100755
index 540fc68c9c..0000000000
--- a/ext/spl/examples/ini_groups.php
+++ /dev/null
@@ -1,41 +0,0 @@
-<?php
-
-/** @file ini_groups.php
- * @brief Program List groups within an ini file
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage: php dba_dump.php \<file\> [\<regex\>]
- *
- * Show all groups in the ini file specified by \<file\>.
- * The regular expression \<regex\> is used to filter the result.
- *
- * Note: configure with --enable-dba
- */
-
-if ($argc < 2) {
- echo <<<EOF
-Usage: php dba_dump.php <file> [<regex>]
-
-Show all groups in the ini file specified by <file>.
-The regular expression <regex> is used to filter the result.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("KeyFilter", false)) require_once("keyfilter.inc");
-if (!class_exists("IniGroups", false)) require_once("inigroups.inc");
-
-$it = new IniGroups($argv[1]);
-if ($argc>2) {
- $it = new KeyFilter($it, $argv[2]);
-}
-
-foreach($it as $group) {
- echo "$group\n";
-}
-
-?>
diff --git a/ext/spl/examples/inigroups.inc b/ext/spl/examples/inigroups.inc
deleted file mode 100644
index d33f169c4b..0000000000
--- a/ext/spl/examples/inigroups.inc
+++ /dev/null
@@ -1,54 +0,0 @@
-<?php
-
-/** @file inigroups.inc
- * @ingroup Examples
- * @brief class IniGroups
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-if (!class_exists("KeyFilter", false)) require_once("keyfilter.inc");
-if (!class_exists("DbaReader", false)) require_once("dbareader.inc");
-
-/** @ingroup Examples
- * @brief Class to iterate all groups within an ini file.
- * @author Marcus Boerger
- * @version 1.1
- *
- * Using this class you can iterator over all groups of a ini file.
- *
- * This class uses a 'is-a' relation to KeyFilter in contrast to a 'has-a'
- * relation. Doing so both current() and key() methods must be overwritten.
- * If it would use a 'has-a' relation there would be much more to type...
- * but for puritists that would allow correctness in so far as then no
- * key() would be needed.
- */
-class IniGroups extends KeyFilter
-{
- /**
- * Construct an ini file group iterator from a filename.
- *
- * @param file Ini file to open.
- */
- function __construct($file) {
- parent::__construct(new DbaReader($file, 'inifile'), '^\[.*\]$');
- }
-
- /**
- * @return The current group.
- */
- function current() {
- return substr(parent::key(),1,-1);
- }
-
- /**
- * @return The current group.
- */
- function key() {
- return substr(parent::key(),1,-1);
- }
-}
-
-?>
diff --git a/ext/spl/examples/keyfilter.inc b/ext/spl/examples/keyfilter.inc
deleted file mode 100644
index 21bb79a2d1..0000000000
--- a/ext/spl/examples/keyfilter.inc
+++ /dev/null
@@ -1,64 +0,0 @@
-<?php
-
-/** @file keyfilter.inc
- * @ingroup Examples
- * @brief class KeyFilter
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief Regular expression filter for string iterators
- * @author Marcus Boerger
- * @version 1.1
- *
- * Instances of this class act as a filter around iterators whose elements
- * are strings. In other words you can put an iterator into the constructor
- * and the instance will only return elements which match the given regular
- * expression.
- */
-class KeyFilter extends FilterIterator
-{
- /** @internal regular exoression used as filter */
- private $regex;
-
- /**
- * Constructs a filter around an iterator whose elemnts are strings.
- * If the given iterator is of type spl_sequence then its rewind()
- * method is called.
- *
- * @param it Object that implements at least spl_forward
- * @param regex Regular expression used as a filter.
- */
- function __construct(Iterator $it, $regex)
- {
- parent::__construct($it);
- $this->regex = $regex;
- }
-
- /** \return whether the current key mathes the regular expression
- */
- function accept()
- {
- return ereg($this->regex, $this->getInnerIterator()->key());
- }
-
- /** @return regular expression used as filter
- */
- function getRegex()
- {
- return $this->regex;
- }
-
- /**
- * hidden __clone
- */
- protected function __clone()
- {
- // disallow clone
- }
-}
-
-?>
diff --git a/ext/spl/examples/nocvsdir.php b/ext/spl/examples/nocvsdir.php
deleted file mode 100755
index d8e4362ab6..0000000000
--- a/ext/spl/examples/nocvsdir.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-/** @file nocvsdir.php
- * @brief Program Dir without CVS subdirs
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2006
- * @version 1.1
- *
- * Usage: php nocvsdir.php \<path\>
- *
- * Simply specify the path to tree with parameter \<path\>.
- */
-
-if ($argc < 2) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <path>
-
-Show the directory and all it's contents without any CVS directory in <path>.
-
-<path> The directory for which to generate the directory.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("RecursiveFilterIterator")) require_once("recursivefilteriterator.inc");
-
-class NoCvsDirectory extends RecursiveFilterIterator
-{
- function __construct($path)
- {
- parent::__construct(new RecursiveDirectoryIterator($path));
- }
-
- function accept()
- {
- return $this->getInnerIterator()->getFilename() != 'CVS';
- }
-
- function getChildren()
- {
- return new NoCvsDirectory($this->key());
- }
-}
-
-$it = new RecursiveIteratorIterator(new NoCvsDirectory($argv[1]));
-
-foreach($it as $pathname => $file)
-{
- echo $pathname."\n";
-}
-
-?>
diff --git a/ext/spl/examples/phar_from_dir.php b/ext/spl/examples/phar_from_dir.php
deleted file mode 100755
index 23fcfc9777..0000000000
--- a/ext/spl/examples/phar_from_dir.php
+++ /dev/null
@@ -1,50 +0,0 @@
-<?php
-
-/** @file phar_from_dir.php
- * @brief Create phar archive from directory
- * @ingroup examples
- * @author Marcus Boerger
- * @date 2003 - 2007
- * @version 1.0
- *
- * Usage: php phar_create_from_dir.php \<archive\> \<directory\> [\<regex\>]
- *
- * Create phar archive \<archive\> using entries from \<directory\> that
- * optionally match \<regex\>.
- */
-
-if ($argc < 3)
-{
- echo <<<EOF
-php phar_from_dir.php archive directory [regex]
-
-Packs files in a given directory into a phar archive.
-
-archive name of the archive to create
-directory input directory to pack
-regex optional expression to match files in directory
-
-EOF;
- exit(1);
-}
-
-$phar = new Phar($argv[1], 0, 'newphar');
-
-$dir = new RecursiveDirectoryIterator($argv[2]);
-$dir = new RecursiveIteratorIterator($dir);
-if ($argc > 3)
-{
- $dir = new RegexIterator($dir, '/'.$argv[3].'/');
-}
-
-$phar->begin();
-
-foreach($dir as $file)
-{
- echo "$file\n";
- copy($file, "phar://newphar/$file");
-}
-
-$phar->commit();
-
-?>
diff --git a/ext/spl/examples/regexfindfile.inc b/ext/spl/examples/regexfindfile.inc
deleted file mode 100644
index 395624b8de..0000000000
--- a/ext/spl/examples/regexfindfile.inc
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-/** @file regexfindfile.inc
- * @ingroup Examples
- * @brief class RegexFindFile
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief Find files by regular expression
- * @author Marcus Boerger
- * @version 1.1
- *
- */
-class RegexFindFile extends FindFile
-{
- /** Construct from path and regular expression
- *
- * @param $path the directory to search in
- * If path contains ';' then this parameter is split and every
- * part of it is used as separate directory.
- * @param $regex perl style regular expression to find files with
- */
- function __construct($path, $regex)
- {
- parent::__construct($path, $regex);
- }
-
- /** @return whether the current filename matches the regular expression.
- */
- function accept()
- {
- return preg_match($this->getSearch(), $this->current());
- }
-}
-
-?>
diff --git a/ext/spl/examples/searchiterator.inc b/ext/spl/examples/searchiterator.inc
deleted file mode 100644
index 451ae08fd2..0000000000
--- a/ext/spl/examples/searchiterator.inc
+++ /dev/null
@@ -1,58 +0,0 @@
-<?php
-
-/** @file searchiterator.inc
- * @ingroup Examples
- * @brief abstract class SearchIterator
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup Examples
- * @brief Iterator to search for a specific element
- * @author Marcus Boerger
- * @version 1.0
- *
- * This extended FilterIterator stops after finding the first acceptable
- * value.
- */
-abstract class SearchIterator extends FilterIterator
-{
- /** @internal whether an entry was found already */
- private $done = false;
-
- /** Rewind and reset so that it once again searches.
- * @return void
- */
- function rewind()
- {
- parent::rewind();
- $this->done = false;
- }
-
- /** @return whether the current element is valid
- * which can only happen once per iteration.
- */
- function valid()
- {
- return !$this->done && parent::valid();
- }
-
- /** Do not move forward but instead mark as finished.
- * @return void
- */
- function next()
- {
- $this->done = true;
- }
-
- /** Aggregates the inner iterator
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->getInnerIterator(), $func), $params);
- }
-}
-
-?>
diff --git a/ext/spl/examples/tests/examples.inc b/ext/spl/examples/tests/examples.inc
deleted file mode 100644
index 7502514659..0000000000
--- a/ext/spl/examples/tests/examples.inc
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-class IncludeFiles extends ArrayIterator
-{
- function __construct($path, $classes)
- {
- parent::__construct();
- foreach($classes as $c)
- {
- $this->append($path . '/' . strtolower($c) . '.inc');
- }
- }
-}
-
-$classes = array(
-);
-
-foreach (new IncludeFiles(dirname(__FILE__). '/..', $classes) as $file)
-{
- require_once($file);
-}
-
-?>
diff --git a/ext/spl/examples/tree.php b/ext/spl/examples/tree.php
deleted file mode 100755
index 9c2cc55866..0000000000
--- a/ext/spl/examples/tree.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-/** @file tree.php
- * @brief Program Tree view example
- * @ingroup Examples
- * @author Marcus Boerger
- * @date 2003 - 2005
- *
- * Usage: php tree.php \<path\>
- *
- * Simply specify the path to tree with parameter \<path\>.
- */
-
-// The following line only operates on classes which are converted to c already.
-// But does not generate a graphical output.
-//foreach(new RecursiveIteratorIterator(new ParentIterator(new RecursiveDirectoryIterator($argv[1])), 1) as $file) {
-
-if ($argc < 2) {
- echo <<<EOF
-Usage: php ${_SERVER['PHP_SELF']} <path>
-
-Displays a graphical tree for the given <path>.
-
-<path> The directory for which to generate the tree graph.
-
-
-EOF;
- exit(1);
-}
-
-if (!class_exists("DirectoryTreeIterator", false)) require_once("directorytreeiterator.inc");
-if (!class_exists("DirectoryGraphIterator", false)) require_once("directorygraphiterator.inc");
-
-echo $argv[1]."\n";
-foreach(new DirectoryGraphIterator($argv[1]) as $file)
-{
- echo $file . "\n";
-}
-
-?>
diff --git a/ext/spl/internal/appenditerator.inc b/ext/spl/internal/appenditerator.inc
deleted file mode 100644
index 72eb258136..0000000000
--- a/ext/spl/internal/appenditerator.inc
+++ /dev/null
@@ -1,122 +0,0 @@
-<?php
-
-/** @file appenditerator.inc
- * @ingroup SPL
- * @brief class AppendIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief Iterator that iterates over several iterators one after the other
- * @author Marcus Boerger
- * @version 1.0
- * @since PHP 5.1
- */
-class AppendIterator implements OuterIterator
-{
- /** @internal array of inner iterators */
- private $iterators;
-
- /** Construct an empty AppendIterator
- */
- function __construct()
- {
- $this->iterators = new ArrayIterator();
- }
-
- /** Append an Iterator
- * @param $it Iterator to append
- *
- * If the current state is invalid but the appended iterator is valid
- * the AppendIterator itself becomes valid. However there will be no
- * call to $it->rewind(). Also if the current state is invalid the inner
- * ArrayIterator will be rewound und forwarded to the appended element.
- */
- function append(Iterator $it)
- {
- $this->iterators->append($it);
- }
-
- /** @return the current inner Iterator
- */
- function getInnerIterator()
- {
- return $this->iterators->current();
- }
-
- /** Rewind to the first element of the first inner Iterator.
- * @return void
- */
- function rewind()
- {
- $this->iterators->rewind();
- if ($this->iterators->valid())
- {
- $this->getInnerIterator()->rewind();
- }
- }
-
- /** @return whether the current element is valid
- */
- function valid()
- {
- return $this->iterators->valid() && $this->getInnerIterator()->valid();
- }
-
- /** @return the current value if it is valid or \c NULL
- */
- function current()
- {
- /* Using $this->valid() would be exactly the same; it would omit
- * the access to a non valid element in the inner iterator. Since
- * the user didn't respect the valid() return value false this
- * must be intended hence we go on. */
- return $this->iterators->valid() ? $this->getInnerIterator()->current() : NULL;
- }
-
- /** @return the current key if it is valid or \c NULL
- */
- function key()
- {
- return $this->iterators->valid() ? $this->getInnerIterator()->key() : NULL;
- }
-
- /** Move to the next element. If this means to another Iterator that
- * rewind that Iterator.
- * @return void
- */
- function next()
- {
- if (!$this->iterators->valid())
- {
- return; /* done all */
- }
- $this->getInnerIterator()->next();
- if ($this->getInnerIterator()->valid())
- {
- return; /* found valid element in current inner iterator */
- }
- $this->iterators->next();
- while ($this->iterators->valid())
- {
- $this->getInnerIterator()->rewind();
- if ($this->getInnerIterator()->valid())
- {
- return; /* found element as first elemet in another iterator */
- }
- $this->iterators->next();
- }
- }
-
- /** Aggregates the inner iterator
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->getInnerIterator(), $func), $params);
- }
-}
-
-?>
diff --git a/ext/spl/internal/cachingiterator.inc b/ext/spl/internal/cachingiterator.inc
deleted file mode 100644
index 077ac726cf..0000000000
--- a/ext/spl/internal/cachingiterator.inc
+++ /dev/null
@@ -1,157 +0,0 @@
-<?php
-
-/** @file cachingiterator.inc
- * @ingroup SPL
- * @brief class CachingIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Cached iteration over another Iterator
- * @author Marcus Boerger
- * @version 1.2
- * @since PHP 5.0
- *
- * This iterator wrapper does a one ahead iteration. This way it knows whether
- * the inner iterator has one more element.
- *
- * @note If you want to convert the elements into strings and the inner
- * Iterator is an internal Iterator then you need to provide the
- * flag CALL_TOSTRING to do the conversion when the actual element
- * is being fetched. Otherwise the conversion would happen with the
- * already changed iterator. If you do not need this then it you should
- * omit this flag because it costs unnecessary work and time.
- */
-class CachingIterator implements OuterIterator
-{
- const CALL_TOSTRING = 0x00000001;
- const CATCH_GET_CHILD = 0x00000002;
- const TOSTRING_USE_KEY = 0x00000010;
- const TOSTRING_USE_CURRENT = 0x00000020;
-
- private $it;
- private $current;
- private $key;
- private $valid;
- private $strValue;
-
- /** Construct from another iterator
- *
- * @param it Iterator to cache
- * @param flags Bitmask:
- * - CALL_TOSTRING (whether to call __toString() for every element)
- */
- function __construct(Iterator $it, $flags = self::CALL_TOSTRING)
- {
- if ((($flags & self::CALL_TOSTRING) && ($flags & (self::TOSTRING_USE_KEY|self::TOSTRING_USE_CURRENT)))
- || ((flags & (self::CIT_TOSTRING_USE_KEY|self::CIT_TOSTRING_USE_CURRENT)) == (self::CIT_TOSTRING_USE_KEY|self::CIT_TOSTRING_USE_CURRENT)))
- {
- throw new InvalidArgumentException('Flags must contain only one of CIT_CALL_TOSTRING, CIT_TOSTRING_USE_KEY, CIT_TOSTRING_USE_CURRENT');
- }
- $this->it = $it;
- $this->flags = $flags & (0x0000FFFF);
- $this->next();
- }
-
- /** Rewind the Iterator
- */
- function rewind()
- {
- $this->it->rewind();
- $this->next();
- }
-
- /** Forward to the next element
- */
- function next()
- {
- if ($this->valid = $this->it->valid()) {
- $this->current = $this->it->current();
- $this->key = $this->it->key();
- if ($this->flags & self::CALL_TOSTRING) {
- if (is_object($this->current)) {
- $this->strValue = $this->current->__toString();
- } else {
- $this->strValue = (string)$this->current;
- }
- }
- } else {
- $this->current = NULL;
- $this->key = NULL;
- $this->strValue = NULL;
- }
- $this->it->next();
- }
-
- /** @return whether the iterator is valid
- */
- function valid()
- {
- return $this->valid;
- }
-
- /** @return whether there is one more element
- */
- function hasNext()
- {
- return $this->it->valid();
- }
-
- /** @return the current element
- */
- function current()
- {
- return $this->current;
- }
-
- /** @return the current key
- */
- function key()
- {
- return $this->key;
- }
-
- /** Aggregate the inner iterator
- *
- * @param func Name of method to invoke
- * @param params Array of parameters to pass to method
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->it, $func), $params);
- }
-
- /** @return the string represenatation that was generated for the current
- * element
- * @throw exception when CALL_TOSTRING was not specified in constructor
- */
- function __toString()
- {
- if ($this->flags & self::TOSTRING_USE_KEY)
- {
- return $this->key;
- }
- else if ($this->flags & self::TOSTRING_USE_CURRENT)
- {
- return $this->current;
- }
- if (!$this->flags & self::CALL_TOSTRING)
- {
- throw new exception('CachingIterator does not fetch string value (see CachingIterator::__construct)');
- }
- return $this->strValue;
- }
-
- /**
- * @return The inner iterator
- */
- function getInnerIterator()
- {
- return $this->it;
- }
-}
-
-?>
diff --git a/ext/spl/internal/emptyiterator.inc b/ext/spl/internal/emptyiterator.inc
deleted file mode 100644
index c7a05717a6..0000000000
--- a/ext/spl/internal/emptyiterator.inc
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-/** @file emptyiterator.inc
- * @ingroup SPL
- * @brief class EmptyIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief An empty Iterator
- * @author Marcus Boerger
- * @version 1.0
- * @since PHP 5.1
- */
-class EmptyIterator implements Iterator
-{
- /** No operation.
- * @return void
- */
- function rewind()
- {
- // nothing to do
- }
-
- /** @return \c false
- */
- function valid()
- {
- return false;
- }
-
- /** This function must not be called. It throws an exception upon access.
- * @throw Exception
- * @return void
- */
- function current()
- {
- throw new Exception('Accessing the value of an EmptyIterator');
- }
-
- /** This function must not be called. It throws an exception upon access.
- * @throw Exception
- * @return void
- */
- function key()
- {
- throw new Exception('Accessing the key of an EmptyIterator');
- }
-
- /** No operation.
- * @return void
- */
- function next()
- {
- // nothing to do
- }
-}
-
-?>
diff --git a/ext/spl/internal/filteriterator.inc b/ext/spl/internal/filteriterator.inc
deleted file mode 100644
index 27cb9c064f..0000000000
--- a/ext/spl/internal/filteriterator.inc
+++ /dev/null
@@ -1,127 +0,0 @@
-<?php
-
-/** @file filteriterator.inc
- * @ingroup SPL
- * @brief class FilterIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Abstract filter for iterators
- * @author Marcus Boerger
- * @version 1.1
- * @since PHP 5.0
- *
- * Instances of this class act as a filter around iterators. In other words
- * you can put an iterator into the constructor and the instance will only
- * return selected (accepted) elements.
- *
- * The only thing that needs to be done to make this work is implementing
- * method accept(). Typically this invloves reading the current element or
- * key of the inner Iterator and checking whether it is acceptable.
- */
-abstract class FilterIterator implements OuterIterator
-{
- private $it;
-
- /**
- * Constructs a filter around another iterator.
- *
- * @param it Iterator to filter
- */
- function __construct(Iterator $it) {
- $this->it = $it;
- }
-
- /**
- * Rewind the inner iterator.
- */
- function rewind() {
- $this->it->rewind();
- $this->fetch();
- }
-
- /**
- * Accept function to decide whether an element of the inner iterator
- * should be accessible through the Filteriterator.
- *
- * @return whether or not to expose the current element of the inner
- * iterator.
- */
- abstract function accept();
-
- /**
- * Fetch next element and store it.
- *
- * @return void
- */
- protected function fetch() {
- while ($this->it->valid()) {
- if ($this->accept()) {
- return;
- }
- $this->it->next();
- };
- }
-
- /**
- * Move to next element
- *
- * @return void
- */
- function next() {
- $this->it->next();
- $this->fetch();
- }
-
- /**
- * @return Whether more elements are available
- */
- function valid() {
- return $this->it->valid();
- }
-
- /**
- * @return The current key
- */
- function key() {
- return $this->it->key();
- }
-
- /**
- * @return The current value
- */
- function current() {
- return $this->it->current();
- }
-
- /**
- * hidden __clone
- */
- protected function __clone() {
- // disallow clone
- }
-
- /**
- * @return The inner iterator
- */
- function getInnerIterator()
- {
- return $this->it;
- }
-
- /** Aggregate the inner iterator
- *
- * @param func Name of method to invoke
- * @param params Array of parameters to pass to method
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->it, $func), $params);
- }
-}
-
-?>
diff --git a/ext/spl/internal/infiniteiterator.inc b/ext/spl/internal/infiniteiterator.inc
deleted file mode 100644
index ffd728cf09..0000000000
--- a/ext/spl/internal/infiniteiterator.inc
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-/** @file infiniteiterator.inc
- * @ingroup SPL
- * @brief class InfiniteIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief An infinite Iterator
- * @author Marcus Boerger
- * @version 1.1
- * @since PHP 5.1
- *
- * This Iterator takes another Iterator and infinitvely iterates it by
- * rewinding it when its end is reached.
- *
- * \note Even an InfiniteIterator stops if its inner Iterator is empty.
- *
- \verbatim
- $it = new ArrayIterator(array(1,2,3));
- $infinite = new InfiniteIterator($it);
- $limit = new LimitIterator($infinite, 0, 5);
- foreach($limit as $val=>$key)
- {
- echo "$val=>$key\n";
- }
- \endverbatim
- */
-class InfiniteIterator extends IteratorIterator
-{
- /** Move the inner Iterator forward to its next element or rewind it.
- * @return void
- */
- function next()
- {
- $this->getInnerIterator()->next();
- if (!$this->getInnerIterator()->valid())
- {
- $this->getInnerIterator()->rewind();
- }
- }
-}
-
-?>
diff --git a/ext/spl/internal/iteratoriterator.inc b/ext/spl/internal/iteratoriterator.inc
deleted file mode 100644
index cdf89d8306..0000000000
--- a/ext/spl/internal/iteratoriterator.inc
+++ /dev/null
@@ -1,121 +0,0 @@
-<?php
-
-/** @file iteratoriterator.inc
- * @ingroup SPL
- * @brief class IteratorIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief Basic Iterator wrapper
- * @since PHP 5.1
- *
- * This iterator wrapper allows to convert anything that is traversable into
- * an Iterator. It is very important to understand that most classes that do
- * not implement Iterator have their reasone to. Most likely they do not allow
- * the full Iterator feature set. If so you need to provide techniques to
- * prevent missuse. If you do not you must expect exceptions or fatal errors.
- *
- * It is also possible to derive the class and implement IteratorAggregate by
- * downcasting the instances returned in getIterator. See the following
- * example (assuming BaseClass implements Traversable):
- \code
- class SomeClass extends BaseClass implements IteratorAggregate
- {
- function getIterator()
- {
- return new IteratorIterator($this, 'BaseClass');
- }
- }
- \endcode
- *
- * As you can see in the example this approach requires that the class to
- * downcast to is actually a base class of the specified iterator to wrap.
- * Omitting the downcast in the above example would result in an endless loop
- * since IteratorIterator::__construct() would call SomeClass::getIterator().
- */
-class IteratorIterator implements OuterIterator
-{
- /** Construct an IteratorIterator from an Iterator or an IteratorAggregate.
- *
- * @param iterator inner iterator
- * @param classname optional class the iterator has to be downcasted to
- */
- function __construct(Traversable $iterator, $classname = null)
- {
- if ($iterator instanceof IteratorAggregate)
- {
- $iterator = $iterator->getIterator();
- }
- if ($iterator instanceof Iterator)
- {
- $this->iterator = $iterator;
- }
- else
- {
- throw new Exception("Classes that only implement Traversable can be wrapped only after converting class IteratorIterator into c code");
- }
- }
-
- /** \return the inner iterator as passed to the constructor
- */
- function getInnerIterator()
- {
- return $this->iterator;
- }
-
- /** \return whether the iterator is valid
- */
- function valid()
- {
- return $this->iterator->valid();
- }
-
- /** \return current key
- */
- function key()
- {
- return $this->iterator->key();
- }
-
- /** \return current value
- */
- function current()
- {
- return $this->iterator->current();
- }
-
- /** forward to next element
- */
- function next()
- {
- return $this->iterator->next();
- }
-
- /** rewind to the first element
- */
- function rewind()
- {
- return $this->iterator->rewind();
- }
-
- /** Aggregate the inner iterator
- *
- * @param func Name of method to invoke
- * @param params Array of parameters to pass to method
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->iterator, $func), $params);
- }
-
- /** The inner iterator must be private because when this class will be
- * converted to c code it won't no longer be available.
- */
- private $iterator;
-}
-
-?>
diff --git a/ext/spl/internal/limititerator.inc b/ext/spl/internal/limititerator.inc
deleted file mode 100644
index 78c96d1049..0000000000
--- a/ext/spl/internal/limititerator.inc
+++ /dev/null
@@ -1,134 +0,0 @@
-<?php
-
-/** @file limititerator.inc
- * @ingroup SPL
- * @brief class LimitIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Limited Iteration over another Iterator
- * @author Marcus Boerger
- * @version 1.1
- * @since PHP 5.0
- *
- * A class that starts iteration at a certain offset and only iterates over
- * a specified amount of elements.
- *
- * This class uses SeekableIterator::seek() if available and rewind() plus
- * a skip loop otehrwise.
- */
-class LimitIterator implements OuterIterator
-{
- private $it;
- private $offset;
- private $count;
- private $pos;
-
- /** Construct
- *
- * @param it Iterator to limit
- * @param offset Offset to first element
- * @param count Maximum number of elements to show or -1 for all
- */
- function __construct(Iterator $it, $offset = 0, $count = -1)
- {
- if ($offset < 0) {
- throw new exception('Parameter offset must be > 0');
- }
- if ($count < 0 && $count != -1) {
- throw new exception('Parameter count must either be -1 or a value greater than or equal to 0');
- }
- $this->it = $it;
- $this->offset = $offset;
- $this->count = $count;
- $this->pos = 0;
- }
-
- /** Seek to specified position
- * @param position offset to seek to (relative to beginning not offset
- * specified in constructor).
- * @throw exception when position is invalid
- */
- function seek($position) {
- if ($position < $this->offset) {
- throw new exception('Cannot seek to '.$position.' which is below offset '.$this->offset);
- }
- if ($position > $this->offset + $this->count && $this->count != -1) {
- throw new exception('Cannot seek to '.$position.' which is behind offset '.$this->offset.' plus count '.$this->count);
- }
- if ($this->it instanceof SeekableIterator) {
- $this->it->seek($position);
- $this->pos = $position;
- } else {
- while($this->pos < $position && $this->it->valid()) {
- $this->next();
- }
- }
- }
-
- /** Rewind to offset specified in constructor
- */
- function rewind()
- {
- $this->it->rewind();
- $this->pos = 0;
- $this->seek($this->offset);
- }
-
- /** @return whether iterator is valid
- */
- function valid() {
- return ($this->count == -1 || $this->pos < $this->offset + $this->count)
- && $this->it->valid();
- }
-
- /** @return current key
- */
- function key() {
- return $this->it->key();
- }
-
- /** @return current element
- */
- function current() {
- return $this->it->current();
- }
-
- /** Forward to nect element
- */
- function next() {
- $this->it->next();
- $this->pos++;
- }
-
- /** @return current position relative to zero (not to offset specified in
- * constructor).
- */
- function getPosition() {
- return $this->pos;
- }
-
- /**
- * @return The inner iterator
- */
- function getInnerIterator()
- {
- return $this->it;
- }
-
- /** Aggregate the inner iterator
- *
- * @param func Name of method to invoke
- * @param params Array of parameters to pass to method
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->it, $func), $params);
- }
-}
-
-?>
diff --git a/ext/spl/internal/multipleiterator.inc b/ext/spl/internal/multipleiterator.inc
deleted file mode 100644
index 12df011ecc..0000000000
--- a/ext/spl/internal/multipleiterator.inc
+++ /dev/null
@@ -1,223 +0,0 @@
-<?php
-/** @file multipleiterator.inc
- * @ingroup SPL
- * @brief class MultipleIterator
- * @author Johannes Schlueter
- * @author Marcus Boerger
- * @date 2008 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief Iterator that iterates over several iterators one after the other
- * @author Johannes Schlueter
- * @author Marcus Boerger
- * @version 1.0
- * @since PHP 5.3
- */
-class MultipleIterator implements Iterator
-{
- /** Inner Iterators */
- private $iterators;
-
- /** Flags: const MIT_* */
- private $flags;
-
- /** do not require all sub iterators to be valid in iteration */
- const MIT_NEED_ANY = 0;
-
- /** require all sub iterators to be valid in iteration */
- const MIT_NEED_ALL = 1;
-
- /** keys are created from sub iterators position */
- const MIT_KEYS_NUMERIC = 0;
-
- /** keys are created from sub iterators associated infromation */
- const MIT_KEYS_ASSOC = 2;
-
- /** Construct a new empty MultipleIterator
- * @param flags MIT_* flags
- */
- public function __construct($flags = self::MIT_NEED_ALL|self::MIT_KEYS_NUMERIC)
- {
- $this->iterators = new SplObjectStorage();
- $this->flags = $flags;
- }
-
- /** @return current flags MIT_* */
- public function getFlags()
- {
- return $this->flags;
- }
-
- /** @param $flags new flags. */
- public function setFlags($flags)
- {
- $this->flags = $flags;
- }
-
- /** @param $iter new Iterator to attach.
- * @param $inf associative info forIteraotr, must be NULL, integer or string
- *
- * @throws IllegalValueException if a inf is none of NULL, integer or string
- * @throws IllegalValueException if a inf is already an associated info
- */
- public function attachIterator(Iterator $iter, $inf = NULL)
- {
-
- if (!is_null($inf))
- {
- if (!is_int($inf) && !is_string($inf))
- {
- throw new IllegalValueException('Inf must be NULL, integer or string');
- }
- foreach($this->iterators as $iter)
- {
- if ($inf == $this->iterators->getInfo())
- {
- throw new IllegalValueException('Key duplication error');
- }
- }
- }
- $this->iterators->attach($iter, $inf);
- }
-
- /** @param $iter attached Iterator that should be detached. */
- public function detachIterator(Iterator $iter)
- {
- $this->iterators->detach($iter);
- }
-
- /** @param $iter Iterator to check
- * @return whether $iter is attached or not
- */
- public function containsIterator(Iterator $iter)
- {
- return $this->iterator->contains($iter);
- }
-
- /** @return number of attached Iterator instances. */
- public function countIterators()
- {
- return $this->iterators->count();
- }
-
- /** Rewind all attached Iterator instances. */
- public function rewind()
- {
- foreach($this->iterators as $iter)
- {
- $iter->rewind();
- }
- }
-
- /**
- * @return whether all or one sub iterator is valid depending on flags.
- * In mode MIT_NEED_ALL we expect all sub iterators to be valid and
- * return flase on the first non valid one. If that flag is not set we
- * return true on the first valid sub iterator found. If no Iterator
- * is attached, we always return false.
- */
- public function valid()
- {
- if (!sizeof($this->iterators)) {
- return false;
- }
- // The following code is an optimized version that executes as few
- // valid() calls as necessary and that only checks the flags once.
- $expect = $this->flags & self::MIT_NEED_ALL ? true : false;
- foreach($this->iterators as $iter)
- {
- if ($expect != $iter->valid())
- {
- return !$expect;
- }
- }
- return $expect;
- }
-
- /** Move all attached Iterator instances forward. That is invoke
- * their next() method regardless of their state.
- */
- public function next()
- {
- foreach($this->iterators as $iter)
- {
- $iter->next();
- }
- }
-
- /** @return false if no sub Iterator is attached and an array of
- * all registered Iterator instances current() result.
- * @throws RuntimeException if mode MIT_NEED_ALL is set and at least one
- * attached Iterator is not valid().
- * @throws IllegalValueException if a key is NULL and MIT_KEYS_ASSOC is set.
- */
- public function current()
- {
- if (!sizeof($this->iterators))
- {
- return false;
- }
- $retval = array();
- foreach($this->iterators as $iter)
- {
- if ($iter->valid())
- {
- if ($this->flags & self::MIT_KEYS_ASSOC)
- {
- $key = $this->iterators->getInfo();
- if (is_null($key))
- {
- throw new IllegalValueException('Sub-Iterator is associated with NULL');
- }
- $retval[$key] = $iter->current();
- }
- else
- {
- $retval[] = $iter->current();
- }
- }
- else if ($this->flags & self::MIT_NEED_ALL)
- {
- throw new RuntimeException('Called current() with non valid sub iterator');
- }
- else
- {
- $retval[] = NULL;
- }
- }
- return $retval;
- }
-
- /** @return false if no sub Iterator is attached and an array of
- * all registered Iterator instances key() result.
- * @throws LogicException if mode MIT_NEED_ALL is set and at least one
- * attached Iterator is not valid().
- */
- public function key()
- {
- if (!sizeof($this->iterators))
- {
- return false;
- }
- $retval = array();
- foreach($this->iterators as $iter)
- {
- if ($iter->valid())
- {
- $retval[] = $iter->key();
- }
- else if ($this->flags & self::MIT_NEED_ALL)
- {
- throw new LogicException('Called key() with non valid sub iterator');
- }
- else
- {
- $retval[] = NULL;
- }
- }
- return $retval;
- }
-}
diff --git a/ext/spl/internal/norewinditerator.inc b/ext/spl/internal/norewinditerator.inc
deleted file mode 100644
index 6b61dbba02..0000000000
--- a/ext/spl/internal/norewinditerator.inc
+++ /dev/null
@@ -1,28 +0,0 @@
-<?php
-
-/** @file norewinditerator.inc
- * @ingroup SPL
- * @brief class NoRewindIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief An Iterator wrapper that doesn't call rewind
- * @author Marcus Boerger
- * @version 1.1
- * @since PHP 5.1
- */
-class NoRewindIterator extends IteratorIterator
-{
- /** Simply prevent execution of inner iterators rewind().
- */
- function rewind()
- {
- // nothing to do
- }
-}
-
-?>
diff --git a/ext/spl/internal/outeriterator.inc b/ext/spl/internal/outeriterator.inc
deleted file mode 100644
index c2684ae51c..0000000000
--- a/ext/spl/internal/outeriterator.inc
+++ /dev/null
@@ -1,25 +0,0 @@
-<?php
-
-/** @file outeriterator.inc
- * @ingroup SPL
- * @brief class OuterIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Interface to access the current inner iteraor of iterator wrappers
- * @author Marcus Boerger
- * @version 1.0
- * @since PHP 5.1
- */
-interface OuterIterator extends Iterator
-{
- /** @return inner iterator
- */
- function getInnerIterator();
-}
-
-?>
diff --git a/ext/spl/internal/parentiterator.inc b/ext/spl/internal/parentiterator.inc
deleted file mode 100644
index e3c5605f83..0000000000
--- a/ext/spl/internal/parentiterator.inc
+++ /dev/null
@@ -1,32 +0,0 @@
-<?php
-
-/** @file parentiterator.inc
- * @ingroup SPL
- * @brief class FilterIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Iterator to filter parents
- * @author Marcus Boerger
- * @version 1.2
- * @since PHP 5.1
- *
- * This extended FilterIterator allows a recursive iteration using
- * RecursiveIteratorIterator that only shows those elements which have
- * children.
- */
-class ParentIterator extends RecursiveFilterIterator
-{
- /** @return whetehr the current element has children
- */
- function accept()
- {
- return $this->it->hasChildren();
- }
-}
-
-?>
diff --git a/ext/spl/internal/recursivearrayiterator.inc b/ext/spl/internal/recursivearrayiterator.inc
deleted file mode 100644
index 418fb0d9e1..0000000000
--- a/ext/spl/internal/recursivearrayiterator.inc
+++ /dev/null
@@ -1,59 +0,0 @@
-<?php
-
-/** @file recursivearrayiterator.inc
- * @ingroup Examples
- * @brief class RecursiveArrayIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief A recursive array iterator
- * @author Marcus Boerger
- * @version 1.0
- * @since PHP 5.1
- *
- * Passes the RecursiveIterator interface to the inner Iterator and provides
- * the same functionality as FilterIterator. This allows you to skip parents
- * and all their childs before loading them all. You need to care about
- * function getChildren() because it may not always suit your needs. The
- * builtin behavior uses reflection to return a new instance of the exact same
- * class it is called from. That is you extend RecursiveFilterIterator and
- * getChildren() will create instance of that class. The problem is that doing
- * this does not transport any state or control information of your accept()
- * implementation to the new instance. To overcome this problem you might
- * need to overwrite getChildren(), call this implementation and pass the
- * control vaules manually.
- */
-class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
-{
- /** @return whether the current element has children
- */
- function hasChildren()
- {
- return is_array($this->current());
- }
-
- /** @return an iterator for the current elements children
- *
- * @note the returned iterator will be of the same class as $this
- */
- function getChildren()
- {
- if ($this->current() instanceof self)
- {
- return $this->current();
- }
- if (empty($this->ref))
- {
- $this->ref = new ReflectionClass($this);
- }
- return $this->ref->newInstance($this->current());
- }
-
- private $ref;
-}
-
-?>
diff --git a/ext/spl/internal/recursivecachingiterator.inc b/ext/spl/internal/recursivecachingiterator.inc
deleted file mode 100644
index fcbbda7042..0000000000
--- a/ext/spl/internal/recursivecachingiterator.inc
+++ /dev/null
@@ -1,99 +0,0 @@
-<?php
-
-/** @file recursivecachingiterator.inc
- * @ingroup SPL
- * @brief class RecursiveCachingIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Cached recursive iteration over another Iterator
- * @author Marcus Boerger
- * @version 1.2
- * @since PHP 5.1
- *
- * @see CachingIterator
- */
-class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
-{
- private $hasChildren;
- private $getChildren;
-
- /** Construct from another iterator
- *
- * @param it Iterator to cache
- * @param flags Bitmask:
- * - CALL_TOSTRING (whether to call __toString() for every element)
- * - CATCH_GET_CHILD (whether to catch exceptions when trying to get childs)
- */
- function __construct(RecursiveIterator $it, $flags = self::CALL_TOSTRING)
- {
- parent::__construct($it, $flags);
- }
-
- /** Rewind Iterator
- */
- function rewind();
- {
- $this->hasChildren = false;
- $this->getChildren = NULL;
- parent::rewind();
- }
-
- /** Forward to next element if necessary then an Iterator for the Children
- * will be created.
- */
- function next()
- {
- if ($this->hasChildren = $this->it->hasChildren())
- {
- try
- {
- $child = $this->it->getChildren();
- if (!$this->ref)
- {
- $this->ref = new ReflectionClass($this);
- }
- $this->getChildren = $ref->newInstance($child, $this->flags);
- }
- catch(Exception $e)
- {
- if (!$this->flags & self::CATCH_GET_CHILD)
- {
- throw $e;
- }
- $this->hasChildren = false;
- $this->getChildren = NULL;
- }
- } else
- {
- $this->getChildren = NULL;
- }
- parent::next();
- }
-
- private $ref;
-
- /** @return whether the current element has children
- * @note The check whether the Iterator for the children can be created was
- * already executed. Hence when flag CATCH_GET_CHILD was given in
- * constructor this function returns false so that getChildren does
- * not try to access those children.
- */
- function hasChildren()
- {
- return $this->hasChildren;
- }
-
- /** @return An Iterator for the children
- */
- function getChildren()
- {
- return $this->getChildren;
- }
-}
-
-?>
diff --git a/ext/spl/internal/recursivefilteriterator.inc b/ext/spl/internal/recursivefilteriterator.inc
deleted file mode 100644
index 2c0d9ef998..0000000000
--- a/ext/spl/internal/recursivefilteriterator.inc
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-/** @file recursivefilteriterator.inc
- * @ingroup SPL
- * @brief class RecursiveFilterIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief Iterator to filter recursive iterators
- * @author Marcus Boerger
- * @version 1.0
- * @since PHP 5.1
- *
- * Passes the RecursiveIterator interface to the inner Iterator and provides
- * the same functionality as FilterIterator. This allows you to skip parents
- * and all their childs before loading them all. You need to care about
- * function getChildren() because it may not always suit your needs. The
- * builtin behavior uses reflection to return a new instance of the exact same
- * class it is called from. That is you extend RecursiveFilterIterator and
- * getChildren() will create instance of that class. The problem is that doing
- * this does not transport any state or control information of your accept()
- * implementation to the new instance. To overcome this problem you might
- * need to overwrite getChildren(), call this implementation and pass the
- * control vaules manually.
- */
-abstract class RecursiveFilterIterator extends FilterIterator implements RecursiveIterator
-{
- /** @param $it the RecursiveIterator to filter
- */
- function __construct(RecursiveIterator $it)
- {
- parent::__construct($it);
- }
-
- /** @return whether the current element has children
- */
- function hasChildren()
- {
- return $this->getInnerIterator()->hasChildren();
- }
-
- /** @return an iterator for the current elements children
- *
- * @note the returned iterator will be of the same class as $this
- */
- function getChildren()
- {
- if (empty($this->ref))
- {
- $this->ref = new ReflectionClass($this);
- }
- return $this->ref->newInstance($this->getInnerIterator()->getChildren());
- }
-
- private $ref;
-}
-
-?>
diff --git a/ext/spl/internal/recursiveiterator.inc b/ext/spl/internal/recursiveiterator.inc
deleted file mode 100644
index a89fbd8577..0000000000
--- a/ext/spl/internal/recursiveiterator.inc
+++ /dev/null
@@ -1,30 +0,0 @@
-<?php
-
-/** @file recursiveiterator.inc
- * @ingroup SPL
- * @brief class RecursiveIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Interface for recursive iteration with RecursiveIteratorIterator
- * @author Marcus Boerger
- * @version 1.0
- * @since PHP 5.0
- */
-interface RecursiveIterator extends Iterator
-{
- /** @return whether the current element has children
- */
- function hasChildren();
-
- /** @return the sub iterator for the current element
- * @note The returned object must implement RecursiveIterator.
- */
- function getChildren();
-}
-
-?>
diff --git a/ext/spl/internal/recursiveiteratoriterator.inc b/ext/spl/internal/recursiveiteratoriterator.inc
deleted file mode 100644
index 46110c9fb9..0000000000
--- a/ext/spl/internal/recursiveiteratoriterator.inc
+++ /dev/null
@@ -1,237 +0,0 @@
-<?php
-
-/** @file recursiveiteratoriterator.inc
- * @ingroup SPL
- * @brief class RecursiveIteratorIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Iterates through recursive iterators
- * @author Marcus Boerger
- * @version 1.2
- * @since PHP 5.0
- *
- * The objects of this class are created by instances of RecursiveIterator.
- * Elements of those iterators may be traversable themselves. If so these
- * sub elements are recursed into.
- */
-class RecursiveIteratorIterator implements OuterIterator
-{
- /** Mode: Only show leaves */
- const LEAVES_ONLY = 0;
- /** Mode: Show parents prior to their children */
- const SELF_FIRST = 1;
- /** Mode: Show all children prior to their parent */
- const CHILD_FIRST = 2;
-
- /** Flag: Catches exceptions during getChildren() calls and simply jumps
- * to the next element. */
- const CATCH_GET_CHILD = 0x00000002;
-
- private $ait = array();
- private $count = 0;
- private $mode = self::LEAVES_ONLY;
- private $flags = 0;
-
- /** Construct from RecursiveIterator
- *
- * @param it RecursiveIterator to iterate
- * @param mode Operation mode (one of):
- * - LEAVES_ONLY only show leaves
- * - SELF_FIRST show parents prior to their childs
- * - CHILD_FIRST show all children prior to their parent
- * @param flags Control flags, zero or any combination of the following
- * (since PHP 5.1).
- * - CATCH_GET_CHILD which catches exceptions during
- * getChildren() calls and simply jumps to the next
- * element.
- */
- function __construct(RecursiveIterator $it, $mode = self::LEAVES_ONLY, $flags = 0)
- {
- $this->ait[0] = $it;
- $this->mode = $mode;
- $this->flags = $flags;
- }
-
- /** Rewind to top iterator as set in constructor
- */
- function rewind()
- {
- while ($this->count) {
- unset($this->ait[$this->count--]);
- $this->endChildren();
- }
- $this->ait[0]->rewind();
- $this->ait[0]->recursed = false;
- callNextElement(true);
- }
-
- /** @return whether iterator is valid
- */
- function valid()
- {
- $count = $this->count;
- while ($count) {
- $it = $this->ait[$count];
- if ($it->valid()) {
- return true;
- }
- $count--;
- $this->endChildren();
- }
- return false;
- }
-
- /** @return current key
- */
- function key()
- {
- $it = $this->ait[$this->count];
- return $it->key();
- }
-
- /** @return current element
- */
- function current()
- {
- $it = $this->ait[$this->count];
- return $it->current();
- }
-
- /** Forward to next element
- */
- function next()
- {
- while ($this->count) {
- $it = $this->ait[$this->count];
- if ($it->valid()) {
- if (!$it->recursed && callHasChildren()) {
- $it->recursed = true;
- try
- {
- $sub = callGetChildren();
- }
- catch (Exception $e)
- {
- if (!($this->flags & self::CATCH_GET_CHILD))
- {
- throw $e;
- }
- $it->next();
- continue;
- }
- $sub->recursed = false;
- $sub->rewind();
- if ($sub->valid()) {
- $this->ait[++$this->count] = $sub;
- if (!$sub instanceof RecursiveIterator) {
- throw new Exception(get_class($sub).'::getChildren() must return an object that implements RecursiveIterator');
- }
- $this->beginChildren();
- return;
- }
- unset($sub);
- }
- $it->next();
- $it->recursed = false;
- if ($it->valid()) {
- return;
- }
- $it->recursed = false;
- }
- if ($this->count) {
- unset($this->ait[$this->count--]);
- $it = $this->ait[$this->count];
- $this->endChildren();
- callNextElement(false);
- }
- }
- callNextElement(true);
- }
-
- /** @return Sub Iterator at given level or if unspecified the current sub
- * Iterator
- */
- function getSubIterator($level = NULL)
- {
- if (is_null($level)) {
- $level = $this->count;
- }
- return @$this->ait[$level];
- }
-
- /**
- * @return The inner iterator
- */
- function getInnerIterator()
- {
- return $this->it;
- }
-
- /** @return Current Depth (Number of parents)
- */
- function getDepth()
- {
- return $this->level;
- }
-
- /** @return whether current sub iterators current element has children
- * @since PHP 5.1
- */
- function callHasChildren()
- {
- return $this->ait[$this->count]->hasChildren();
- }
-
- /** @return current sub iterators current children
- * @since PHP 5.1
- */
- function callGetChildren()
- {
- return $this->ait[$this->count]->getChildren();
- }
-
- /** Called right after calling getChildren() and its rewind().
- * @since PHP 5.1
- */
- function beginChildren()
- {
- }
-
- /** Called after current child iterator is invalid and right before it
- * gets destructed.
- * @since PHP 5.1
- */
- function endChildren()
- {
- }
-
- private function callNextElement($after_move)
- {
- if ($this->valid())
- {
- if ($after_move)
- {
- if (($this->mode == self::SELF_FIRST && $this->callHasChildren())
- || $this->mode == self::LEAVES_ONLY)
- $this->nextElement();
- }
- else
- {
- $this->nextElement();
- }
- }
- }
-
- /** Called when the next element is available
- */
- function nextElement()
- {
- }
-}
-
-?>
diff --git a/ext/spl/internal/recursiveregexiterator.inc b/ext/spl/internal/recursiveregexiterator.inc
deleted file mode 100644
index 51cf6c415f..0000000000
--- a/ext/spl/internal/recursiveregexiterator.inc
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-/** @file recursiveregexiterator.inc
- * @ingroup SPL
- * @brief class RegexIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Recursive regular expression filter for iterators
- * @author Marcus Boerger
- * @version 1.0
- * @since PHP 5.1
- *
- * This filter iterator assumes that the inner iterator
- */
-class RecursiveRegexIterator extends RegexIterator implements RecursiveIterator
-{
- /**
- * Constructs a regular expression filter around an iterator whose
- * elemnts or keys are strings.
- *
- * @param it inner iterator
- * @param regex the regular expression to match
- * @param mode operation mode (one of self::MATCH, self::GET_MATCH,
- * self::ALL_MATCHES, self::SPLIT)
- * @param flags special flags (self::USE_KEY)
- * @param preg_flags global PREG_* flags, see preg_match(),
- * preg_match_all(), preg_split()
- */
- function __construct(RecursiveIterator $it, $regex, $mode = 0, $flags = 0, $preg_flags = 0) {
- parent::__construct($it, $regex, $mode, $flags, $preg_flags);
- }
-
- /** @return whether the current element has children
- */
- function hasChildren()
- {
- return $this->getInnerIterator()->hasChildren();
- }
-
- /** @return an iterator for the current elements children
- *
- * @note the returned iterator will be of the same class as $this
- */
- function getChildren()
- {
- if (empty($this->ref))
- {
- $this->ref = new ReflectionClass($this);
- }
- return $this->ref->newInstance($this->getInnerIterator()->getChildren());
- }
-
- private $ref;
-}
-
-?>
diff --git a/ext/spl/internal/recursivetreeiterator.inc b/ext/spl/internal/recursivetreeiterator.inc
deleted file mode 100644
index a2312414ea..0000000000
--- a/ext/spl/internal/recursivetreeiterator.inc
+++ /dev/null
@@ -1,132 +0,0 @@
-<?php
-
-/** @file recursivetreeiterator.inc
- * @ingroup SPL
- * @brief class RecursiveTreeIterator
- * @author Marcus Boerger, Johannes Schlueter
- * @date 2005 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-
-/** @ingroup SPL
- * @brief RecursiveIteratorIterator to generate ASCII graphic trees for the
- * entries in a RecursiveIterator
- * @author Marcus Boerger, Johannes Schlueter
- * @version 1.1
- * @since PHP 5.3
- */
-class RecursiveTreeIterator extends RecursiveIteratorIterator
-{
- const BYPASS_CURRENT = 0x00000004;
- const BYPASS_KEY = 0x00000008;
-
- private $rit_flags;
-
- /**
- * @param it iterator to use as inner iterator
- * @param rit_flags flags passed to RecursiveIteratoIterator (parent)
- * @param cit_flags flags passed to RecursiveCachingIterator (for hasNext)
- * @param mode mode passed to RecursiveIteratoIterator (parent)
- */
- function __construct(RecursiveIterator $it, $rit_flags = self::BYPASS_KEY, $cit_flags = CachingIterator::CATCH_GET_CHILD, $mode = self::SELF_FIRST)
- {
- parent::__construct(new RecursiveCachingIterator($it, $cit_flags), $mode, $rit_flags);
- $this->rit_flags = $rit_flags;
- }
-
- private $prefix = array(0=>'', 1=>'| ', 2=>' ', 3=>'|-', 4=>'\-', 5=>'');
-
- /** Prefix used to start elements. */
- const PREFIX_LEFT = 0;
- /** Prefix used if $level < depth and hasNext($level) == true. */
- const PREFIX_MID_HAS_NEXT = 1;
- /** Prefix used if $level < depth and hasNext($level) == false. */
- const PREFIX_MID_LAST = 2;
- /** Prefix used if $level == depth and hasNext($level) == true. */
- const PREFIX_END_HAS_NEXT = 3;
- /** Prefix used if $level == depth and hasNext($level) == false. */
- const PREFIX_END_LAST = 4;
- /** Prefix used right in front of the current element. */
- const PREFIX_RIGHT = 5;
-
- /**
- * Set prefix part as used in getPrefix() and stored in $prefix.
- * @param $part any PREFIX_* const.
- * @param $value new prefix string for specified part.
- * @throws OutOfRangeException if 0 > $part or $part > 5.
- */
- function setPrefixPart($part, $value)
- {
- if (0 > $part || $part > 5) {
- throw new OutOfRangeException();
- }
- $this->prefix[$part] = (string)$value;
- }
-
- /** @return string to place in front of current element
- */
- function getPrefix()
- {
- $tree = '';
- for ($level = 0; $level < $this->getDepth(); $level++)
- {
- $tree .= $this->getSubIterator($level)->hasNext() ? $this->prefix[1] : $this->prefix[2];
- }
- $tree .= $this->getSubIterator($level)->hasNext() ? $this->prefix[3] : $this->prefix[4];
-
- return $this->prefix[0] . $tree . $this->prefix[5];
- }
-
- /** @return string presentation build for current element
- */
- function getEntry()
- {
- return @(string)parent::current();
- }
-
- /** @return string to place after the current element
- */
- function getPostfix()
- {
- return '';
- }
-
- /** @return the current element prefixed and postfixed
- */
- function current()
- {
- if ($this->rit_flags & self::BYPASS_CURRENT)
- {
- return parent::current();
- }
- else
- {
- return $this->getPrefix() . $this->getEntry() . $this->getPostfix();
- }
- }
-
- /** @return the current key prefixed and postfixed
- */
- function key()
- {
- if ($this->rit_flags & self::BYPASS_KEY)
- {
- return parent::key();
- }
- else
- {
- return $this->getPrefix() . parent::key() . $this->getPostfix();
- }
- }
-
- /** Aggregates the inner iterator
- */
- function __call($func, $params)
- {
- return call_user_func_array(array($this->getSubIterator(), $func), $params);
- }
-}
-
-?>
diff --git a/ext/spl/internal/regexiterator.inc b/ext/spl/internal/regexiterator.inc
deleted file mode 100644
index 706eff33a7..0000000000
--- a/ext/spl/internal/regexiterator.inc
+++ /dev/null
@@ -1,170 +0,0 @@
-<?php
-
-/** @file regexiterator.inc
- * @ingroup SPL
- * @brief class RegexIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Regular expression filter for iterators
- * @author Marcus Boerger
- * @version 1.0
- * @since PHP 5.1
- *
- * This filter iterator assumes that the inner iterator
- */
-class RegexIterator extends FilterIterator
-{
- const USE_KEY = 0x00000001; /**< If present in $flags the key is
- used rather then the current value. */
-
- const MATCH = 0; /**< Mode: Executed a plain match only */
- const GET_MATCH = 1; /**< Mode: Return the first matche (if any) */
- const ALL_MATCHES = 2; /**< Mode: Return all matches (if any) */
- const SPLIT = 3; /**< Mode: Return the split values (if any) */
- const REPLACE = 4; /**< Mode: Replace the input key or current */
-
- private $regex; /**< the regular expression to match against */
- private $mode; /**< operation mode (one of self::MATCH,
- self::GET_MATCH, self::ALL_MATCHES, self::SPLIT) */
- private $flags; /**< special flags (self::USE_KEY) */
- private $preg_flags;/**< PREG_* flags, see preg_match(), preg_match_all(),
- preg_split() */
- private $key; /**< the value used for key() */
- private $current; /**< the value used for current() */
-
- /**
- * Constructs a regular expression filter around an iterator whose
- * elemnts or keys are strings.
- *
- * @param it inner iterator
- * @param regex the regular expression to match
- * @param mode operation mode (one of self::MATCH, self::GET_MATCH,
- * self::ALL_MATCHES, self::SPLIT)
- * @param flags special flags (self::USE_KEY)
- * @param preg_flags global PREG_* flags, see preg_match(),
- * preg_match_all(), preg_split()
- */
- function __construct(Iterator $it, $regex, $mode = 0, $flags = 0, $preg_flags = 0) {
- parent::__construct($it);
- $this->regex = $regex;
- $this->flags = $flags;
- $this->mode = $mode;
- $this->preg_flags = $preg_flags;
- }
-
- /**
- * Match current or key against regular expression using mode, flags and
- * preg_flags.
- *
- * @return whether this is a match
- *
- * @warning never call this twice for the same state
- */
- function accept()
- {
- $matches = array();
- $this->key = parent::key();
- $this->current = parent::current();
- /* note that we use $this->current, rather than calling parent::current() */
- $subject = ($this->flags & self::USE_KEY) ? $this->key : $this->current;
- switch($this->mode)
- {
- case self::MATCH:
- return preg_match($this->regex, $subject, $matches, $this->preg_flags);
-
- case self::GET_MATCH:
- $this->current = array();
- return preg_match($this->regex, $subject, $this->current, $this->preg_flags) > 0;
-
- case self::ALL_MATCHES:
- $this->current = array();
- return preg_match_all($this->regex, $subject, $this->current, $this->preg_flags) > 0;
-
- case self::SPLIT:
- $this->current = array();
- preg_split($this->regex, $subject, $this->current, $this->preg_flags) > 1;
-
- case self::REPLACE:
- $this->current = array();
- $result = preg_replace($this->regex, $this->replacement, $subject);
- if ($this->flags & self::USE_KEY)
- {
- $this->key = $result;
- }
- else
- {
- $this->current = $result;
- }
- }
- }
-
- /** @return the key after accept has been called
- */
- function key()
- {
- return $this->key;
- }
-
- /** @return the current value after accept has been called
- */
- function current()
- {
- return $this->current;
- }
-
- /** @return current operation mode
- */
- function getMode()
- {
- return $this->mode;
- }
-
- /** @param mode new operaion mode
- */
- function setMode($mode)
- {
- $this->mode = $mode;
- }
-
- /** @return current operation flags
- */
- function getFlags()
- {
- return $this->flags;
- }
-
- /** @param flags new operaion flags
- */
- function setFlags($flags)
- {
- $this->flags = $flags;
- }
-
- /** @return current PREG flags
- */
- function getPregFlags()
- {
- return $this->preg_flags;
- }
-
- /** @param preg_flags new PREG flags
- */
- function setPregFlags($preg_flags)
- {
- $this->preg_flags = $preg_flags;
- }
-
- /** @return current regular expression
- */
- function getRegex()
- {
- return $this->regex;
- }
-}
-
-?>
diff --git a/ext/spl/internal/seekableiterator.inc b/ext/spl/internal/seekableiterator.inc
deleted file mode 100644
index 83e5588c74..0000000000
--- a/ext/spl/internal/seekableiterator.inc
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-/** @file seekableiterator.inc
- * @ingroup SPL
- * @brief class SeekableIterator
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @brief seekable iterator
- * @author Marcus Boerger
- * @version 1.0
- * @since PHP 5.0
- *
- * Turns a normal iterator ino a seekable iterator. When there is a way
- * to seek on an iterator LimitIterator can use this to efficiently rewind
- * to offset.
- */
-interface SeekableIterator extends Iterator
-{
- /** Seek to an absolute position
- *
- * \param $index position to seek to
- * \return void
- *
- * The method should throw an exception if it is not possible to seek to
- * the given position. Typically this exception should be of type
- * OutOfBoundsException.
- \code
- function seek($index);
- $this->rewind();
- $position = 0;
- while($position < $index && $this->valid()) {
- $this->next();
- $position++;
- }
- if (!$this->valid()) {
- throw new OutOfBoundsException('Invalid seek position');
- }
- }
- \endcode
- */
- function seek($index);
-}
-
-?>
diff --git a/ext/spl/internal/spldoublylinkedlist.inc b/ext/spl/internal/spldoublylinkedlist.inc
deleted file mode 100644
index f01b6306a7..0000000000
--- a/ext/spl/internal/spldoublylinkedlist.inc
+++ /dev/null
@@ -1,277 +0,0 @@
-<?php
-/** @file spldoublylinkedlist.inc
- * @ingroup SPL
- * @brief class SplDoublyLinkedList
- * @author Etienne Kneuss
- * @date 2008 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief Doubly Linked List
- * @since PHP 5.3
- *
- * The SplDoublyLinkedList class provides the main functionalities of a
- * doubly linked list (DLL).
- * @note The following userland implementation of Iterator is a bit different
- * from the internal one. Internally, iterators generated by nested
- * foreachs are independent, while they share the same traverse pointer
- * in userland.
- */
-class SplDoublyLinkedList implements Iterator, ArrayAccess, Countable
-{
- protected $_llist = array();
- protected $_it_mode = 0;
- protected $_it_pos = 0;
-
- /** Iterator mode
- * @see setIteratorMode
- */
- const IT_MODE_LIFO = 0x00000002;
-
- /** Iterator mode
- * @see setIteratorMode
- */
- const IT_MODE_FIFO = 0x00000000;
-
- /** Iterator mode
- * @see setIteratorMode
- */
- const IT_MODE_KEEP = 0x00000000;
-
- /** Iterator mode
- * @see setIteratorMode
- */
- const IT_MODE_DELETE = 0x00000001;
-
- /** @return the element popped from the end of the DLL.
- * @throw RuntimeException If the datastructure is empty.
- */
- public function pop()
- {
- if (count($this->_llist) == 0) {
- throw new RuntimeException("Can't pop from an empty datastructure");
- }
- return array_pop($this->_llist);
- }
-
- /** @return the element shifted from the beginning of the DLL.
- * @throw RuntimeException If the datastructure is empty.
- */
- public function shift()
- {
- if (count($this->_llist) == 0) {
- throw new RuntimeException("Can't shift from an empty datastructure");
- }
- return array_shift($this->_llist);
- }
-
- /** Pushes an element to the end of the DLL.
- * @param $data variable to add to the DLL.
- */
- public function push($data)
- {
- array_push($this->_llist, $data);
- return true;
- }
-
- /** Adds an element to the beginning of the DLL.
- * @param $data variable to add to the DLL.
- */
- public function unshift($data)
- {
- array_unshift($this->_llist, $data);
- return true;
- }
-
- /** @return the element at the beginning of the DLL.
- */
- public function top()
- {
- return end($this->_llist);
- }
-
- /** @return the element at the end of the DLL.
- */
- public function bottom()
- {
- return reset($this->_llist);
- }
-
- /** @return number elements in the DLL.
- */
- public function count()
- {
- return count($this->_llist);
- }
-
- /** @return whether the DLL is empty.
- */
- public function isEmpty()
- {
- return ($this->count() == 0);
- }
-
- /** Changes the iteration mode. There are two orthogonal sets of modes that
- * can be set:
- * - The direction of the iteration (either one or the other)
- * - SplDoublyLnkedList::IT_MODE_LIFO (Stack style)
- * - SplDoublyLnkedList::IT_MODE_FIFO (Queue style)
- *
- * - The behavior of the iterator (either one or the other)
- * - SplDoublyLnkedList::IT_MODE_DELETE (Elements are deleted by the iterator)
- * - SplDoublyLnkedList::IT_MODE_KEEP (Elements are traversed by the iterator)
- *
- * The default mode is 0 : SplDoublyLnkedList::IT_MODE_FIFO | SplDoublyLnkedList::IT_MODE_KEEP
- *
- * @param $mode new mode of iteration
- */
- public function setIteratorMode($mode)
- {
- $this->_it_mode = $mode;
- }
-
- /** @return the current iteration mode
- * @see setIteratorMode
- */
- public function getIteratorMode()
- {
- return $this->_it_mode;
- }
-
- /** Rewind to top iterator as set in constructor
- */
- public function rewind()
- {
- if ($this->_it_mode & self::IT_MODE_LIFO) {
- $this->_it_pos = count($this->_llist)-1;
- } else {
- $this->_it_pos = 0;
- }
- }
-
- /** @return whether iterator is valid
- */
- public function valid()
- {
- return array_key_exists($this->_it_pos, $this->_llist);
- }
-
- /** @return current key
- */
- public function key()
- {
- return $this->_it_pos;
- }
-
- /** @return current object
- */
- public function current()
- {
- return $this->_llist[$this->_it_pos];
- }
-
- /** Forward to next element
- */
- public function next()
- {
- if ($this->_it_mode & self::IT_MODE_LIFO) {
- if ($this->_it_mode & self::IT_MODE_DELETE) {
- $this->pop();
- }
- $this->_it_pos--;
- } else {
- if ($this->_it_mode & self::IT_MODE_DELETE) {
- $this->shift();
- } else {
- $this->_it_pos++;
- }
- }
- }
-
- /** @return whether a certain offset exists in the DLL
- *
- * @param $offset The offset
- * @throw OutOfRangeException If the offset is either invalid or out of
- * range.
- */
- public function offsetExists($offset)
- {
- if (!is_numeric($offset)) {
- throw new OutOfRangeException("Offset invalid or out of range");
- } else {
- return array_key_exists($offset, $this->_llist);
- }
- }
-
- /** @return the data at a certain offset in the DLL
- *
- * @param $offset The offset
- * @throw OutOfRangeException If the offset is either invalid or out of
- * range.
- */
- public function offsetGet($offset)
- {
- if ($this->_it_mode & self::IT_MODE_LIFO) {
- $realOffset = count($this->_llist)-$offset;
- } else {
- $realOffset = $offset;
- }
-
- if (!is_numeric($offset) || !array_key_exists($realOffset, $this->_llist)) {
- throw new OutOfRangeException("Offset invalid or out of range");
- } else {
- return $this->_llist[$realOffset];
- }
- }
-
- /** Defines the data at a certain offset in the DLL
- *
- * @param $offset The offset
- * @param $value New value
- * @throw OutOfRangeException If the offset is either invalid or out of
- * range.
- */
- public function offsetSet($offset, $value)
- {
- if ($offset === null) {
- return $this->push($value);
- }
-
- if ($this->_it_mode & self::IT_MODE_LIFO) {
- $realOffset = count($this->_llist)-$offset;
- } else {
- $realOffset = $offset;
- }
-
- if (!is_numeric($offset) || !array_key_exists($realOffset, $this->_llist)) {
- throw new OutOfRangeException("Offset invalid or out of range");
- } else {
- $this->_llist[$realOffset] = $value;
- }
- }
-
- /** Unsets the element at a certain offset in the DLL
- *
- * @param $offset The offset
- * @throw OutOfRangeException If the offset is either invalid or out of
- * range.
- */
- public function offsetUnset($offset)
- {
- if ($this->_it_mode & self::IT_MODE_LIFO) {
- $realOffset = count($this->_llist)-$offset;
- } else {
- $realOffset = $offset;
- }
-
- if (!is_numeric($offset) || !array_key_exists($realOffset, $this->_llist)) {
- throw new OutOfRangeException("Offset invalid or out of range");
- } else {
- array_splice($this->_llist, $realOffset, 1);
- }
- }
-}
-
-?>
diff --git a/ext/spl/internal/splfileobject.inc b/ext/spl/internal/splfileobject.inc
deleted file mode 100644
index 4b0c757b81..0000000000
--- a/ext/spl/internal/splfileobject.inc
+++ /dev/null
@@ -1,377 +0,0 @@
-<?php
-
-/** @file splfileobject.inc
- * @ingroup SPL
- * @brief class FileObject
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief Object representation for any stream
- * @author Marcus Boerger
- * @version 1.1
- * @since PHP 5.1
- */
-class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
-{
- /** Flag: wheter to suppress new lines */
- const DROP_NEW_LINE = 0x00000001;
-
- private $fp;
- private $fname;
- private $line = NULL;
- private $lnum = 0;
- private $max_len = 0;
- private $flags = 0;
- private $delimiter= ',';
- private $enclosure= '"';
-
- /**
- * Constructs a new file object
- *
- * @param $file_name The name of the stream to open
- * @param $open_mode The file open mode
- * @param $use_include_path Whether to search in include paths
- * @param $context A stream context
- * @throw RuntimeException If file cannot be opened (e.g. insufficient
- * access rights).
- */
- function __construct($file_name, $open_mode = 'r', $use_include_path = false, $context = NULL)
- {
- $this->fp = fopen($file_name, $open_mode, $use_include_path, $context);
- if (!$this->fp)
- {
- throw new RuntimeException("Cannot open file $file_name");
- }
- $this->fname = $file_name;
- }
-
- /**
- * @return whether the end of the stream is reached
- */
- function eof()
- {
- return feof($this->fp);
- }
-
- /** increase current line number
- * @return next line from stream
- */
- function fgets()
- {
- $this->freeLine();
- $this->lnum++;
- $buf = fgets($this->fp, $this->max_len);
-
- return $buf;
- }
-
- /**
- * @param delimiter character used as field separator
- * @param enclosure end of
- * @return array containing read data
- */
- function fgetcsv($delimiter = NULL, $enclosure = NULL)
- {
- $this->freeLine();
- $this->lnum++;
- switch(fun_num_args())
- {
- case 0:
- $delimiter = $this->delimiter;
- case 1:
- $enclosure = $this->enclosure;
- default:
- case 2:
- break;
- }
- return fgetcsv($this->fp, $this->max_len, $delimiter, $enclosure);
- }
-
- /**
- * Set the delimiter and enclosure character used in fgetcsv
- *
- * @param delimiter new delimiter, defaults to ','
- * @param enclosure new enclosure, defaults to '"'
- */
- function setCsvControl($delimiter = ';', $enclosure = '"')
- {
- $this->delimiter = $delimiter;
- $this->enclosure = $enclosure;
- }
-
- /**
- * @return array(delimiter, enclosure) as used in fgetcsv
- */
- function getCsvControl($delimiter = ',', $enclosure = '"')
- {
- return array($this->delimiter, $this->enclosure);
- }
-
- /**
- * @param operation lock operation (LOCK_SH, LOCK_EX, LOCK_UN, LOCK_NB)
- * @retval $wouldblock whether the operation would block
- */
- function flock($operation, &$wouldblock)
- {
- return flock($this->fp, $operation, $wouldblock);
- }
-
- /**
- * Flush current data
- * @return success or failure
- */
- function fflush()
- {
- return fflush($this->fp);
- }
-
- /**
- * @return current file position
- */
- function ftell()
- {
- return ftell($this->fp);
- }
-
- /**
- * @param pos new file position
- * @param whence seek method (SEEK_SET, SEEK_CUR, SEEK_END)
- * @return Upon success, returns 0; otherwise, returns -1. Note that
- * seeking past EOF is not considered an error.
- */
- function fseek($pos, $whence = SEEK_SET)
- {
- return fseek($this->fp, $pos, $whence);
- }
-
- /**
- * @return next char from file
- * @note a new line character does not increase $this->lnum
- */
- function fgetc()
- {
- $this->freeLine();
- $c = fgetc($this->fp);
- if ($c == '\n') {
- $this->lnum++;
- }
- }
-
- /** Read and return remaining part of stream
- * @return size of remaining part passed through
- */
- function fpassthru()
- {
- return fpassthru($this->fp);
- }
-
- /** Get a line from the file and strip HTML tags
- * @param $allowable_tags tags to keep in the string
- */
- function fgetss($allowable_tags = NULL)
- {
- return fgetss($this->fp, $allowable_tags);
- }
-
- /** Scan the next line
- * @param $format string specifying format to parse
- */
- function fscanf($format /* , ... */)
- {
- $this->freeLine();
- $this->lnum++;
- return fscanf($this->fp, $format /* , ... */);
- }
-
- /**
- * @param $str to write
- * @param $length maximum line length to write
- */
- function fwrite($str, $length = NULL)
- {
- return fwrite($this->fp, $length);
- }
-
- /**
- * @return array of file stat information
- */
- function fstat()
- {
- return fstat($this->fp);
- }
-
- /**
- * @param $size new size to truncate file to
- */
- function ftruncate($size)
- {
- return ftruncate($this->fp, $size);
- }
-
- /**
- * @param $flags new flag set
- */
- function setFlags($flags)
- {
- $this->flags = $flags;
- }
-
- /**
- * @return current set of flags
- */
- function getFlags()
- {
- return $this->flags;
- }
-
- /**
- * @param $max_len set the maximum line length read
- */
- function setMaxLineLen($max_len)
- {
- $this->max_len = $max_len;
- }
-
- /**
- * @return current setting for max line
- */
- function getMaxLineLen()
- {
- return $this->max_len;
- }
-
- /**
- * @return false
- */
- function hasChildren()
- {
- return false;
- }
-
- /**
- * @return false
- */
- function getChildren()
- {
- return NULL;
- }
-
- /**
- * Invalidate current line buffer and set line number to 0.
- */
- function rewind()
- {
- $this->freeLine();
- $this->lnum = 0;
- }
-
- /**
- * @return whether more data can be read
- */
- function valid()
- {
- return !$this->eof();
- }
-
- /**
- * @note Fill current line buffer if not done yet.
- * @return line buffer
- */
- function current()
- {
- if (is_null($this->line))
- {
- $this->line = getCurrentLine();
- }
- return $this->line;
- }
-
- /**
- * @return line number
- * @note fgetc() will increase the line number when reaing a new line char.
- * This has the effect key() called on a read a new line will already
- * return the increased line number.
- * @note Line counting works as long as you only read the file and do not
- * use fseek().
- */
- function key()
- {
- return $this->lnum;
- }
-
- /** Invalidate current line buffer.
- */
- function next()
- {
- $this->freeLine();
- }
-
- /**
- * @return next line read from file and increase the line counter
- */
- private function readLine()
- {
- if ($this->eof())
- {
- $this->freeLine();
- throw new RuntimeException("Cannot read from file " . $this->fname);
- }
- if ($this->line) {
- $this->lnum++;
- }
- $this->freeLine();
- $this->line = fgets($this->fp, $this->max_len);
- return $this->line;
- }
-
- /**
- * Free the current line buffer and increment the line counter
- */
- private function freeLine()
- {
- if ($this->line) {
- $this->line = NULL;
- }
- }
-
- /*
- * @note If you DO overload this function key() and current() will increment
- * $this->lnum automatically. If not then function reaLine() will do
- * that for you.
- */
- function getCurrentLine()
- {
- $this->freeLine();
- if ($this->eof())
- {
- throw new RuntimeException("Cannot read from file " . $this->fname);
- }
- $this->readLine();
- }
-
- /**
- * @return current line
- */
- function __toString()
- {
- return current();
- }
-
- /**
- * @param $line_pos Seek to this line
- */
- function seek($line_pos)
- {
- $this->rewind();
- while($this->lnum < $line_pos && !$this->eof())
- {
- $this->getCurrentLine();
- }
- }
-}
-
-?>
diff --git a/ext/spl/internal/splobjectstorage.inc b/ext/spl/internal/splobjectstorage.inc
deleted file mode 100644
index f27da4e001..0000000000
--- a/ext/spl/internal/splobjectstorage.inc
+++ /dev/null
@@ -1,188 +0,0 @@
-<?php
-
-/** @file splobjectstorage.inc
- * @ingroup SPL
- * @brief class SplObjectStorage
- * @author Marcus Boerger
- * @date 2003 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/**
- * @brief Object storage
- * @author Marcus Boerger
- * @version 1.1
- * @since PHP 5.1.2
- *
- * This container allows to store objects uniquly without the need to compare
- * them one by one. This is only possible internally. The code representation
- * here therefore has a complexity of O(n) while the actual implementation has
- * complexity O(1).
- */
-class SplObjectStorage implements Iterator, Countable, ArrayAccess
-{
- private $storage = array();
- private $index = 0;
-
- /** Rewind to top iterator as set in constructor
- */
- function rewind()
- {
- rewind($this->storage);
- }
-
- /** @return whether iterator is valid
- */
- function valid()
- {
- return key($this->storage) !== false;
- }
-
- /** @return current key
- */
- function key()
- {
- return $this->index;
- }
-
- /** @return current object
- */
- function current()
- {
- $element = current($this->storage);
- return $element ? $element[0] : NULL
- }
-
- /** @return get current object's associated information
- * @since 5.3.0
- */
- function getInfo()
- {
- $element = current($this->storage);
- return $element ? $element[1] : NULL
- }
-
- /** @return set current object's associated information
- * @since 5.3.0
- */
- function setInfo($inf = NULL)
- {
- if ($this->valid()) {
- $this->storage[$this->index][1] = $inf;
- }
- }
-
- /** Forward to next element
- */
- function next()
- {
- next($this->storage);
- $this->index++;
- }
-
- /** @return number of objects in storage
- */
- function count()
- {
- return count($this->storage);
- }
-
- /** @param $obj object to look for
- * @return whether $obj is contained in storage
- */
- function contains($obj)
- {
- if (is_object($obj))
- {
- foreach($this->storage as $element)
- {
- if ($object === $element[0])
- {
- return true;
- }
- }
- }
- return false;
- }
-
- /** @param $obj new object to attach to storage or object whose
- * associative information is to be replaced
- * @param $inf associative information stored along the object
- */
- function attach($obj, $inf = NULL)
- {
- if (is_object($obj) && !$this->contains($obj))
- {
- $this->storage[] = array($obj, $inf);
- }
- }
-
- /** @param $obj object to remove from storage
- */
- function detach($obj)
- {
- if (is_object($obj))
- {
- foreach($this->storage as $idx => $element)
- {
- if ($object === $element[0])
- {
- unset($this->storage[$idx]);
- $this->rewind();
- return;
- }
- }
- }
- }
-
- /** @param $obj new object to attach to storage or object whose
- * associative information is to be replaced
- * @param $inf associative information stored along the object
- * @since 5.3.0
- */
- function offsetSet($obj, $inf)
- {
- $this->attach($obj, $inf);
- }
-
- /** @param $obj Exising object to look for
- * @return associative information stored with object
- * @throw UnexpectedValueException if Object $obj is not contained in
- * storage
- * @since 5.3.0
- */
- function offsetGet($obj)
- {
- if (is_object($obj))
- {
- foreach($this->storage as $idx => $element)
- {
- if ($object === $element[0])
- {
- return $element[1];
- }
- }
- }
- throw new UnexpectedValueException('Object not found');
- }
-
- /** @param $obj Exising object to look for
- * @return associative information stored with object
- * @since 5.3.0
- */
- function offsetUnset($obj)
- {
- $this->detach($obj);
- }
-
- /** @param $obj object to look for
- * @return whether $obj is contained in storage
- */
- function offsetEsists($obj)
- {
- return $this->contains($obj);
- }
-}
-
-?>
diff --git a/ext/spl/internal/splqueue.inc b/ext/spl/internal/splqueue.inc
deleted file mode 100644
index 259e8ddd12..0000000000
--- a/ext/spl/internal/splqueue.inc
+++ /dev/null
@@ -1,71 +0,0 @@
-<?php
-
-/** @file splqueue.inc
- * @ingroup SPL
- * @brief class SplQueue
- * @author Etienne Kneuss
- * @date 2008 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief Implementation of a Queue through a DoublyLinkedList. As SplQueue
- * extends SplDoublyLinkedList, unshift() and pop() are still available
- * even though they don't make much sense for a queue. For convenience,
- * two aliases are available:
- * - enqueue() is an alias of push()
- * - dequeue() is an alias of shift()
- *
- * @since PHP 5.3
- *
- * The SplQueue class provides the main functionalities of a
- * queue implemented using a doubly linked list (DLL).
- */
-class SplQueue extends SplDoublyLinkedList
-{
- protected $_it_mode = parent::IT_MODE_FIFO;
-
- /** Changes the iteration mode. There are two orthogonal sets of modes that
- * can be set:
- *
- * - The behavior of the iterator (either one or the other)
- * - SplDoublyLnkedList::IT_MODE_DELETE (Elements are deleted by the iterator)
- * - SplDoublyLnkedList::IT_MODE_KEEP (Elements are traversed by the iterator)
- *
- * The default mode is 0 : SplDoublyLnkedList::IT_MODE_LIFO | SplDoublyLnkedList::IT_MODE_KEEP
- *
- * @note The iteration's direction is not modifiable for queue instances
- * @param $mode New mode of iteration
- * @throw RuntimeException If the new mode affects the iteration's direction.
- */
- public function setIteratorMode($mode)
- {
- if ($mode & parent::IT_MODE_LIFO === parent::IT_MODE_LIFO) {
- throw new RuntimeException("Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen");
- }
-
- $this->_it_mode = $mode;
- }
-
- /** @return the first element of the queue.
- * @note dequeue is an alias of push()
- * @see splDoublyLinkedList::push()
- */
- public function dequeue()
- {
- return parent::shift();
- }
-
- /** Pushes an element at the end of the queue.
- * @param $data variable to add to the queue.
- * @note enqueue is an alias of shift()
- * @see splDoublyLinkedList::shift()
- */
- public function enqueue($data)
- {
- return parent::push($data);
- }
-}
-
-?>
diff --git a/ext/spl/internal/splstack.inc b/ext/spl/internal/splstack.inc
deleted file mode 100644
index 05436b585d..0000000000
--- a/ext/spl/internal/splstack.inc
+++ /dev/null
@@ -1,48 +0,0 @@
-<?php
-
-/** @file splstack.inc
- * @ingroup SPL
- * @brief class SplStack
- * @author Etienne Kneuss
- * @date 2008 - 2009
- *
- * SPL - Standard PHP Library
- */
-
-/** @ingroup SPL
- * @brief Implementation of a stack through a DoublyLinkedList. As SplStack
- * extends SplDoublyLinkedList, shift() and unshift() are still available even
- * though they don't make much sense for a stack.
- * @since PHP 5.3
- *
- * The SplStack class provides the main functionalities of a
- * stack implemented using a doubly linked list (DLL).
- */
-class SplStack extends SplDoublyLinkedList
-{
- protected $_it_mode = parent::IT_MODE_LIFO;
-
- /** Changes the iteration mode. There are two orthogonal sets of modes that
- * can be set:
- *
- * - The behavior of the iterator (either one or the other)
- * - SplDoublyLnkedList::IT_MODE_DELETE (Elements are deleted by the iterator)
- * - SplDoublyLnkedList::IT_MODE_KEEP (Elements are traversed by the iterator)
- *
- * The default mode is 0 : SplDoublyLnkedList::IT_MODE_LIFO | SplDoublyLnkedList::IT_MODE_KEEP
- *
- * @note The iteration's direction is not modifiable for stack instances
- * @param $mode New mode of iteration
- * @throw RuntimeException If the new mode affects the iteration's direction.
- */
- public function setIteratorMode($mode)
- {
- if ($mode & parent::IT_MODE_LIFO !== parent::IT_MODE_LIFO) {
- throw new RuntimeException("Iterators' LIFO/FIFO modes for SplStack/SplQueue objects are frozen");
- }
-
- $this->_it_mode = $mode;
- }
-}
-
-?>
diff --git a/ext/spl/php_spl.c b/ext/spl/php_spl.c
index 4da4201f88..b147a96128 100644
--- a/ext/spl/php_spl.c
+++ b/ext/spl/php_spl.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -237,6 +237,10 @@ PHP_FUNCTION(class_uses)
Return an array containing the names of all clsses and interfaces defined in SPL */
PHP_FUNCTION(spl_classes)
{
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
+ }
+
array_init(return_value);
SPL_LIST_CLASSES(return_value, 0, 0, 0)
@@ -387,7 +391,7 @@ static void autoload_func_info_dtor(zval *element)
}
/* {{{ proto void spl_autoload_call(string class_name)
- Try all registerd autoload function to load the requested class */
+ Try all registered autoload function to load the requested class */
PHP_FUNCTION(spl_autoload_call)
{
zval *class_name, retval;
@@ -855,21 +859,20 @@ PHPAPI zend_string *php_spl_object_hash(zval *obj) /* {{{*/
}
/* }}} */
-int spl_build_class_list_string(zval *entry, char **list) /* {{{ */
+static void spl_build_class_list_string(zval *entry, char **list) /* {{{ */
{
char *res;
spprintf(&res, 0, "%s, %s", *list, Z_STRVAL_P(entry));
efree(*list);
*list = res;
- return ZEND_HASH_APPLY_KEEP;
} /* }}} */
/* {{{ PHP_MINFO(spl)
*/
PHP_MINFO_FUNCTION(spl)
{
- zval list;
+ zval list, *zv;
char *strg;
php_info_print_table_start();
@@ -878,7 +881,9 @@ PHP_MINFO_FUNCTION(spl)
array_init(&list);
SPL_LIST_CLASSES(&list, 0, 1, ZEND_ACC_INTERFACE)
strg = estrdup("");
- zend_hash_apply_with_argument(Z_ARRVAL_P(&list), (apply_func_arg_t)spl_build_class_list_string, &strg);
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&list), zv) {
+ spl_build_class_list_string(zv, &strg);
+ } ZEND_HASH_FOREACH_END();
zend_array_destroy(Z_ARR(list));
php_info_print_table_row(2, "Interfaces", strg + 2);
efree(strg);
@@ -886,7 +891,9 @@ PHP_MINFO_FUNCTION(spl)
array_init(&list);
SPL_LIST_CLASSES(&list, 0, -1, ZEND_ACC_INTERFACE)
strg = estrdup("");
- zend_hash_apply_with_argument(Z_ARRVAL_P(&list), (apply_func_arg_t)spl_build_class_list_string, &strg);
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(&list), zv) {
+ spl_build_class_list_string(zv, &strg);
+ } ZEND_HASH_FOREACH_END();
zend_array_destroy(Z_ARR(list));
php_info_print_table_row(2, "Classes", strg + 2);
efree(strg);
@@ -980,11 +987,9 @@ static const zend_function_entry spl_functions[] = {
PHP_FE(class_uses, arginfo_class_uses)
PHP_FE(spl_object_hash, arginfo_spl_object_hash)
PHP_FE(spl_object_id, arginfo_spl_object_id)
-#ifdef SPL_ITERATORS_H
PHP_FE(iterator_to_array, arginfo_iterator_to_array)
PHP_FE(iterator_count, arginfo_iterator)
PHP_FE(iterator_apply, arginfo_iterator_apply)
-#endif /* SPL_ITERATORS_H */
PHP_FE_END
};
/* }}} */
@@ -1054,12 +1059,3 @@ zend_module_entry spl_module_entry = {
STANDARD_MODULE_PROPERTIES_EX
};
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: fdm=marker
- * vim: noet sw=4 ts=4
- */
diff --git a/ext/spl/php_spl.h b/ext/spl/php_spl.h
index e81d048821..69ff65f72c 100644
--- a/ext/spl/php_spl.h
+++ b/ext/spl/php_spl.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -73,12 +73,3 @@ PHP_FUNCTION(class_uses);
PHPAPI zend_string *php_spl_object_hash(zval *obj);
#endif /* PHP_SPL_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/spl.php b/ext/spl/spl.php
deleted file mode 100755
index 8a68613417..0000000000
--- a/ext/spl/spl.php
+++ /dev/null
@@ -1,1160 +0,0 @@
-<?php
-
-/** @file spl.php
- * @ingroup SPL
- * @brief Documentation of internal classes and interfaces
- *
- * SPL - Standard PHP Library
- *
- * (c) Marcus Boerger, 2003 - 2008
- */
-
-/** @mainpage SPL - Standard PHP Library
- *
- * SPL - Standard PHP Library
- *
- * SPL is a collection of interfaces and classes that are meant to solve
- * standard problems and implements some efficient data access interfaces
- * and classes. You'll find the classes documented using php code in the
- * file spl.php or in corresponding .inc files in subdirectories examples
- * and internal. Based on the internal implementations or the files in the
- * examples subdirectory there are also some .php files to experiment with.
- *
- * The .inc files are not included automatically because they are sooner or
- * later integrated into the extension. That means that you either need to
- * put the code of examples/autoload.inc into your autoprepend file or that
- * you have to point your ini setting auto_prepend_file to that file.
- *
- * Below is a list of interfaces/classes already availabel natively through
- * the SPL extension grouped by category.
- *
- * 1) Iterators
- *
- * SPL offers some advanced iterator algorithms:
- *
- * - interface RecursiveIterator extends Iterator
- * - interface OuterIterator extends Iterator
- * - class RecursiveIteratorIterator implements OuterIterator
- * - class RecursiveTreeIterator extends RecursiveIteratorIterator
- * - abstract class FilterIterator implements OuterIterator
- * - class ParentIterator extends FilterIterator implements RecursiveIterator
- * - interface SeekableIterator extends Iterator
- * - class LimitIterator implements OuterIterator
- * - class CachingIterator implements OuterIterator
- * - class RecursiveCachingIterator extends CachingIterator implements RecursiveIterator
- * - class IteratorIterator implements OuterIterator
- * - class NoRewindIterator implements OuterIterator
- * - class EmptyIterator implements Iterator
- * - class InfiniteIterator extends IteratorIterator
- * - class AppendIterator implements OuterIterator
- * - class RegexIterator extends FilterIterator
- * - class RecursiveRegexIterator extends RegexIterator implements RecursiveIterator
- * - class MultipleIterator extends Iterator
- *
- * 2) Directories and Files
- *
- * SPL offers two advanced directory and file handling classes:
- *
- * - class SplFileInfo
- * - class DirectoryIterator extends SplFileInfo implements Iterator
- * - class FilesystemIterator extends DirectoryIterator
- * - class RecursiveDirectoryIterator extends FilesystemIterator implements RecursiveIterator
- * - class GlobIterator extends FilesystemIterator implements Countable
- * - class SplFileObject extends SplFileInfo implements RecursiveIterator, SeekableIterator
- * - class SplTempFileObject extends SplFileObject
- *
- * 3) XML
- *
- * SPL offers an advanced XML handling class:
- *
- * - class SimpleXMLIterator extends simplexml_element implements RecursiveIterator
- *
- * 4) Array Overloading
- *
- * SPL offers advanced Array overloading:
- *
- * - class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
- * - class ArrayIterator implements Iterator, ArrayAccess, Countable, SeekableIterator
- * - class RecursiveArrayIterator extends ArrayIterator implements RecursiveIterator
- * - class SplFixedArray implements Iterator, ArrayAccess, Countable
- *
- * As the above suggest an ArrayObject creates an ArrayIterator when it comes to
- * iteration (e.g. ArrayObject instance used inside foreach).
- *
- * 5) Counting
- *
- * - interface Countable allows to hook into the standard array function count().
- *
- * 6) Exception%s
- *
- * SPL provides a set of standard Exception classes each meant to indicate a
- * certain problem type.
- *
- * - class LogicException extends Exception
- * - class BadFunctionCallException extends LogicException
- * - class BadMethodCallException extends BadFunctionCallException
- * - class DomainException extends LogicException
- * - class InvalidArgumentException extends LogicException
- * - class LengthException extends LogicException
- * - class OutOfRangeException extends LogicException
- * - class RuntimeException extends Exception
- * - class OutOfBoundsException extends RuntimeException
- * - class OverflowException extends RuntimeException
- * - class RangeException extends RuntimeException
- * - class UnderflowException extends RuntimeException
- *
- * 7) Observer
- *
- * SPL suggests a standard way of implementing the observer pattern.
- *
- * - interface SplObserver
- * - interface SplSubject
- * - class SplObjectStorage
- *
- * 8) Datastructures
- *
- * SPL proposes a set of datastructures implemented internally.
- *
- * - class SplDoublyLinkedList
- * - class SplStack extends SplDoublyLinkedList
- * - class SplQueue extends SplDoublyLinkedList
- *
- * 9) @ref Examples
- *
- * The classes and interfaces in this group are contained as PHP code in the
- * examples subdirectory of ext/SPL. Sooner or later they will be moved to
- * c-code.
- *
- * 10) Some articles about SPL:
- * - <a href="http://www.phpro.org/tutorials/Introduction-to-SPL.html">Introduction to Standard PHP Library (SPL)</a>
- * - <a href="http://www.sitepoint.com/article/php5-standard-library/1">Introducing PHP 5's Standard Library</a>
- * - <a href="http://www.ramikayyali.com/archives/2005/02/25/iterators">Iterators in PHP5</a>
- * - <a href="http://www.phpriot.com/d/articles/php/oop/oop-with-spl-php-5-1/index.html">Advanced OOP with SPL in PHP 5</a>
- * - <a href="http://www.devshed.com/c/a/PHP/The-Standard-PHP-Library-Part-1/">The Standard PHP Library, Part 1</a>
- * - <a href="http://www.devshed.com/c/a/PHP/The-Standard-PHP-Library-Part-2/">The Standard PHP Library, Part 2</a>
- * - <a href="http://www.professionelle-softwareentwicklung-mit-php5.de/erste_auflage/oop.iterators.spl.html">Die Standard PHP Library (SPL) [german]</a>
- *
- * 11) Talks on SPL:
- * - SPL Update <a href="http://talks.somabo.de/200702_vancouver_spl_update.pps">[pps]</a>, <a href="http://talks.somabo.de/200702_vancouver_spl_update.pdf">[pdf]</a>
- * - Happy SPLing <a href="http://talks.somabo.de/200509_toronto_happy_spling.pps">[pps]</a>, <a href="http://talks.somabo.de/200509_toronto_happy_spling.pdf">[pdf]</a>
- * - From engine overloading to SPL <a href="http://talks.somabo.de/200505_cancun_from_engine_overloading_to_spl.pps">[pps]</a>, <a href="http://talks.somabo.de/200505_cancun_from_engine_overloading_to_spl.pdf">[pdf]</a>
- * - SPL for the masses <a href="http://talks.somabo.de/200504_php_quebec_spl_for_the_masses.pps">[pps]</a>, <a href="http://talks.somabo.de/200504_php_quebec_spl_for_the_masses.pdf">[pdf]</a>
- *
- * 12) Debug sessions:
- * - Debug session 1 <a href="200407_oscon_introduction_to_iterators_debug.pps">[pps]</a>, <a href="200407_oscon_introduction_to_iterators_debug.pdf">[pdf]</a>
- * - Debug session 2 <a href="http://talks.somabo.de/200509_toronto_iterator_debug_session_1.pps">[pps]</a>, <a href="http://talks.somabo.de/200509_toronto_iterator_debug_session_1.pdf">[pdf]</a>, <a href="http://taks.somabo.de/200411_php_conference_frankfrurt_iterator_debug_session.swf">[swf]</a>
- * - Debug session 3 <a href="http://talks.somabo.de/200509_toronto_iterator_debug_session_2.pps">[pps]</a>, <a href="http://talks.somabo.de/200509_toronto_iterator_debug_session_2.pdf">[pdf]</a>
- *
- * (c) Marcus Boerger, 2003 - 2007
- */
-
-/** @defgroup ZendEngine Zend engine classes
- *
- * The classes and interfaces in this group are contained in the c-code of
- * PHP's Zend engine.
- */
-
-/** @defgroup SPL Internal classes
- *
- * The classes and interfaces in this group are contained in the c-code of
- * ext/SPL.
- */
-
-/** @defgroup Examples Example classes
- *
- * The classes and interfaces in this group are contained as PHP code in the
- * examples subdirectory of ext/SPL. Sooner or later they will be moved to
- * c-code.
- */
-
-/** @ingroup SPL
- * @brief Default implementation for __autoload()
- * @since PHP 5.1
- *
- * @param class_name name of class to load
- * @param file_extensions file extensions (use defaults if NULL)
- */
-function spl_autoload(string $class_name, string $file_extensions = NULL) {/**/};
-
-/** @ingroup SPL
- * @brief Manual invocation of all registerd autoload functions
- * @since PHP 5.1
- *
- * @param class_name name of class to load
- */
-function spl_autoload_call(string $class_name) {/**/};
-
-/** @ingroup SPL
- * @brief Register and return default file extensions for spl_autoload
- * @since PHP 5.1
- *
- * @param file_extensions optional comma separated list of extensions to use in
- * default autoload function. If not given just return the current list.
- * @return comma separated list of file extensions to use in default autoload
- * function.
- */
-function spl_autoload_extensions($file_extensions) {/**/};
-
-/** @ingroup SPL
- * @brief Return all registered autoload functionns
- * @since PHP 5.1
- *
- * @return array of all registered autoload functions or false
- */
-function spl_autoload_functions() {/**/};
-
-/** @ingroup SPL
- * @brief Register given function as autoload implementation
- * @since PHP 5.1
- *
- * @param autoload_function name of function or array of object/class and
- * function name to register as autoload function.
- * @param throw whether to throw or issue an error on failure.
- */
-function spl_autoload_register(string $autoload_function = "spl_autoload", $throw = true) {/**/};
-
-/** @ingroup SPL
- * @brief Unregister given function as autoload implementation
- * @since PHP 5.1
- *
- * @param autoload_function name of function or array of object/class and
- * function name to unregister as autoload function.
- */
-function spl_autoload_unregister(string $autoload_function = "spl_autoload") {/**/};
-
-/** @ingroup SPL
- * @brief Return an array of classes and interfaces in SPL
- *
- * @return array containing the names of all clsses and interfaces defined in
- * extension SPL
- */
-function spl_classes() {/**/};
-
-/** @ingroup SPL
- * @brief Count the elements in an iterator
- * @since PHP 5.1
- *
- * @return number of elements in an iterator
- */
-function iterator_count(Traversable $it) {/**/};
-
-/** @ingroup SPL
- * @brief Copy iterator elements into an array
- * @since PHP 5.1
- *
- * @param it iterator to copy
- * @param use_keys whether touse the keys
- * @return array with elements copied from the iterator
- */
-function iterator_to_array(Traversable $it, $use_keys = true) {/**/};
-
-/** @ingroup ZendEngine
- * @brief Basic Exception class.
- * @since PHP 5.0
- */
-class Exception
-{
- /** The exception message */
- protected $message;
-
- /** The string representations as generated during construction */
- private $string;
-
- /** The code passed to the constructor */
- protected $code;
-
- /** The file name where the exception was instantiated */
- protected $file;
-
- /** The line number where the exception was instantiated */
- protected $line;
-
- /** The stack trace */
- private $trace;
-
- /** Prevent clone
- */
- final private function __clone() {}
-
- /** Construct an exception
- *
- * @param $message Some text describing the exception
- * @param $code Some code describing the exception
- */
- function __construct($message = NULL, $code = 0) {
- if (func_num_args()) {
- $this->message = $message;
- }
- $this->code = $code;
- $this->file = __FILE__; // of throw clause
- $this->line = __LINE__; // of throw clause
- $this->trace = debug_backtrace();
- $this->string = StringFormat($this);
- }
-
- /** @return the message passed to the constructor
- */
- final public function getMessage()
- {
- return $this->message;
- }
-
- /** @return the code passed to the constructor
- */
- final public function getCode()
- {
- return $this->code;
- }
-
- /** @return the name of the file where the exception was thrown
- */
- final public function getFile()
- {
- return $this->file;
- }
-
- /** @return the line number where the exception was thrown
- */
- final public function getLine()
- {
- return $this->line;
- }
-
- /** @return the stack trace as array
- */
- final public function getTrace()
- {
- return $this->trace;
- }
-
- /** @return the stack trace as string
- */
- final public function getTraceAsString()
- {
- }
-
- /** @return string representation of exception
- */
- public function __toString()
- {
- return $this->string;
- }
-}
-
-/** @ingroup SPL
- * @brief Exception that represents error in the program logic.
- * @since PHP 5.1
- *
- * This kind of exceptions should directly leed to a fix in your code.
- */
-class LogicException extends Exception
-{
-}
-
-/** @ingroup SPL
- * @brief Exception thrown when a function call was illegal.
- * @since PHP 5.1
- */
-class BadFunctionCallException extends LogicException
-{
-}
-
-/** @ingroup SPL
- * @brief Exception thrown when a method call was illegal.
- * @since PHP 5.1
- */
-class BadMethodCallException extends BadFunctionCallException
-{
-}
-
-/** @ingroup SPL
- * @brief Exception that denotes a value not in the valid domain was used.
- * @since PHP 5.1
- *
- * This kind of exception should be used to inform about domain erors in
- * mathematical sense.
- *
- * @see RangeException
- */
-class DomainException extends LogicException
-{
-}
-
-/** @ingroup SPL
- * @brief Exception that denotes invalid arguments were passed.
- * @since PHP 5.1
- *
- * @see UnexpectedValueException
- */
-class InvalidArgumentException extends LogicException
-{
-}
-
-/** @ingroup SPL
- * @brief Exception thrown when a parameter exceeds the allowed length.
- * @since PHP 5.1
- *
- * This can be used for strings length, array size, file size, number of
- * elements read from an Iterator and so on.
- */
-class LengthException extends LogicException
-{
-}
-
-/** @ingroup SPL
- * @brief Exception thrown when an illegal index was requested.
- * @since PHP 5.1
- *
- * This represents errors that should be detected at compile time.
- *
- * @see OutOfBoundsException
- */
-class OutOfRangeException extends LogicException
-{
-}
-
-/** @ingroup SPL
- * @brief Exception thrown for errors that are only detectable at runtime.
- * @since PHP 5.1
- */
-class RuntimeException extends Exception
-{
-}
-
-/** @ingroup SPL
- * @brief Exception thrown when an illegal index was requested.
- * @since PHP 5.1
- *
- * This represents errors that cannot be detected at compile time.
- *
- * @see OutOfRangeException
- */
-class OutOfBoundsException extends RuntimeException
-{
-}
-
-/** @ingroup SPL
- * @brief Exception thrown to indicate arithmetic/buffer overflow.
- * @since PHP 5.1
- */
-class OverflowException extends RuntimeException
-{
-}
-
-/** @ingroup SPL
- * @brief Exception thrown to indicate range errors during program execution.
- * @since PHP 5.1
- *
- * Normally this means there was an arithmetic error other than under/overflow.
- * This is the runtime version of DomainException.
- *
- * @see DomainException
- */
-class RangeException extends RuntimeException
-{
-}
-
-/** @ingroup SPL
- * @brief Exception thrown to indicate arithmetic/buffer underflow.
- * @since PHP 5.1
- */
-class UnderflowException extends RuntimeException
-{
-}
-
-/** @ingroup SPL
- * @brief Exception thrown to indicate an unexpected value.
- * @since PHP 5.1
- *
- * Typically this happens when a function calls another function and espects
- * the return value to be of a certain type or value not including arithmetic
- * or buffer related errors.
- *
- * @see InvalidArgumentException
- */
-class UnexpectedValueException extends RuntimeException
-{
-}
-
-/** @ingroup ZendEngine
- * @brief Interface to override array access of objects.
- * @since PHP 5.0
- */
-interface ArrayAccess
-{
- /** @param $offset to modify
- * @param $value new value
- */
- function offsetSet($offset, $value);
-
- /** @param $offset to retrieve
- * @return value at given offset
- */
- function offsetGet($offset);
-
- /** @param $offset to delete
- */
- function offsetUnset($offset);
-
- /** @param $offset to check
- * @return whether the offset exists.
- */
- function offsetExists($offset);
-}
-
-/** @ingroup ZendEngine
- * @brief Interface to detect a class is traversable using foreach.
- * @since PHP 5.0
- *
- * Abstract base interface that cannot be implemented alone. Instead it
- * must be implemented by either IteratorAggregate or Iterator.
- *
- * @note Internal classes that implement this interface can be used in a
- * foreach construct and do not need to implement IteratorAggregate or
- * Iterator.
- *
- * @note This is an engine internal interface which cannot be implemented
- * in PHP scripts. Either IteratorAggregate or Iterator must be used
- * instead.
- */
-interface Traversable
-{
-}
-
-/** @ingroup ZendEngine
- * @brief Interface to create an external Iterator.
- * @since PHP 5.0
- *
- * @note This is an engine internal interface.
- */
-interface IteratorAggregate extends Traversable
-{
- /** @return an Iterator for the implementing object.
- */
- function getIterator();
-}
-
-/** @ingroup ZendEngine
- * @brief Basic iterator
- * @since PHP 5.0
- *
- * Interface for external iterators or objects that can be iterated
- * themselves internally.
- *
- * @note This is an engine internal interface.
- */
-interface Iterator extends Traversable
-{
- /** Rewind the Iterator to the first element.
- */
- function rewind();
-
- /** Return the current element.
- */
- function current();
-
- /** Return the key of the current element.
- */
- function key();
-
- /** Move forward to next element.
- */
- function next();
-
- /** Check if there is a current element after calls to rewind() or next().
- */
- function valid();
-}
-
-/** @ingroup ZendEngine
- * @brief This Interface allows to hook into the global count() function.
- * @since PHP 5.1
- */
-interface Countable
-{
- /** @return the number the global function count() should show
- */
- function count();
-}
-
-/** @ingroup ZendEngine
- * @brief Interface for customized serializing
- * @since 5.1
- *
- * Classes that implement this interface no longer support __sleep() and
- * __wakeup(). The method serialized is called whenever an instance needs to
- * be serialized. This does not invoke __destruct() or has any other side
- * effect unless programmed inside the method. When the data is unserialized
- * the class is known and the appropriate unserialize() method is called as a
- * constructor instead of calling __construct(). If you need to execute the
- * standard constructor you may do so in the method.
- */
-interface Serializable
-{
- /**
- * @return string representation of the instance
- */
- function serialize();
-
- /**
- * @note This is a constructor
- *
- * @param $serialized data read from stream to construct the instance
- */
- function unserialize($serialized);
-}
-
-/** @ingroup SPL
- * @brief An Array wrapper
- * @since PHP 5.0
- * @version 1.2
- *
- * This array wrapper allows to recursively iterate over Arrays and public
- * Object properties.
- *
- * @see ArrayIterator
- */
-class ArrayObject implements IteratorAggregate, ArrayAccess, Countable
-{
- /** Properties of the object have their normal functionality
- * when accessed as list (var_dump, foreach, etc.) */
- const STD_PROP_LIST = 0x00000001;
- /** Array indices can be accessed as properties in read/write */
- const ARRAY_AS_PROPS = 0x00000002;
-
- /** Construct a new array iterator from anything that has a hash table.
- * That is any Array or Object.
- *
- * @param $array the array to use.
- * @param $flags see setFlags().
- * @param $iterator_class class used in getIterator()
- */
- function __construct($array, $flags = 0, $iterator_class = "ArrayIterator") {/**/}
-
- /** Set behavior flags.
- *
- * @param $flags bitmask as follows:
- * 0 set: properties of the object have their normal functionality
- * when accessed as list (var_dump, foreach, etc.)
- * 1 set: array indices can be accessed as properties in read/write
- */
- function setFlags($flags) {/**/}
-
- /** @return current flags
- */
- function getFlags() {/**/}
-
- /** Sort the entries by values.
- */
- function asort() {/**/}
-
- /** Sort the entries by key.
- */
- function ksort() {/**/}
-
- /** Sort the entries by values using user defined function.
- */
- function uasort(mixed cmp_function) {/**/}
-
- /** Sort the entries by key using user defined function.
- */
- function uksort(mixed cmp_function) {/**/}
-
- /** Sort the entries by values using "natural order" algorithm.
- */
- function natsort() {/**/}
-
- /** Sort the entries by values using case insensitive "natural order" algorithm.
- */
- function natcasesort() {/**/}
-
- /** @param $array new array or object
- */
- function exchangeArray($array) {/**/}
-
- /** @return the iterator which is an ArrayIterator object connected to
- * this object.
- */
- function getIterator() {/**/}
-
- /** @param $index offset to inspect
- * @return whetehr offset $index esists
- */
- function offsetExists($index) {/**/}
-
- /** @param $index offset to return value for
- * @return value at offset $index
- */
- function offsetGet($index) {/**/}
-
- /** @param $index index to set
- * @param $newval new value to store at offset $index
- */
- function offsetSet($index, $newval) {/**/}
-
- /** @param $index offset to unset
- */
- function offsetUnset($index) {/**/}
-
- /** @param $value is appended as last element
- * @warning this method cannot be called when the ArrayObject refers to
- * an object.
- */
- function append($value) {/**/}
-
- /** @return a \b copy of the array
- * @note when the ArrayObject refers to an object then this method
- * returns an array of the public properties.
- */
- function getArrayCopy() {/**/}
-
- /** @return the number of elements in the array or the number of public
- * properties in the object.
- */
- function count() {/**/}
-
- /* @param $iterator_class new class used in getIterator()
- */
- function setIteratorClass($itertor_class) {/**/}
-
- /* @return class used in getIterator()
- */
- function getIteratorClass() {/**/}
-}
-
-/** @ingroup SPL
- * @brief An Array iterator
- * @since PHP 5.0
- * @version 1.2
- *
- * This iterator allows to unset and modify values and keys while iterating
- * over Arrays and Objects.
- *
- * When you want to iterate over the same array multiple times you need to
- * instanciate ArrayObject and let it create ArrayIterator instances that
- * refer to it either by using foreach or by calling its getIterator()
- * method manually.
- */
-class ArrayIterator implements SeekableIterator, ArrayAccess, Countable
-{
- /** Properties of the object have their normal functionality
- * when accessed as list (var_dump, foreach, etc.) */
- const STD_PROP_LIST = 0x00000001;
- /** Array indices can be accessed as properties in read/write */
- const ARRAY_AS_PROPS = 0x00000002;
-
- /** Construct a new array iterator from anything that has a hash table.
- * That is any Array or Object.
- *
- * @param $array the array to use.
- * @param $flags see setFlags().
- */
- function __construct($array, $flags = 0) {/**/}
-
- /** Set behavior flags.
- *
- * @param $flags bitmask as follows:
- * 0 set: properties of the object have their normal functionality
- * when accessed as list (var_dump, foreach, etc.)
- * 1 set: array indices can be accessed as properties in read/write
- */
- function setFlags($flags) {/**/}
-
- /**
- * @return current flags
- */
- function getFlags() {/**/}
-
- /** Sort the entries by values.
- */
- function asort() {/**/}
-
- /** Sort the entries by key.
- */
- function ksort() {/**/}
-
- /** Sort the entries by values using user defined function.
- */
- function uasort(mixed cmp_function) {/**/}
-
- /** Sort the entries by key using user defined function.
- */
- function uksort(mixed cmp_function) {/**/}
-
- /** Sort the entries by values using "natural order" algorithm.
- */
- function natsort() {/**/}
-
- /** Sort the entries by values using case insensitive "natural order" algorithm.
- */
- function natcasesort() {/**/}
-
- /** @param $index offset to inspect
- * @return whetehr offset $index esists
- */
- function offsetExists($index) {/**/}
-
- /** @param $index offset to return value for
- * @return value at offset $index
- */
- function offsetGet($index) {/**/}
-
- /** @param $index index to set
- * @param $newval new value to store at offset $index
- */
- function offsetSet($index, $newval) {/**/}
-
- /** @param $index offset to unset
- */
- function offsetUnset($index) {/**/}
-
- /** @param $value is appended as last element
- * @warning this method cannot be called when the ArrayIterator refers to
- * an object.
- */
- function append($value) {/**/}
-
- /** @return a \b copy of the array
- * @note when the ArrayIterator refers to an object then this method
- * returns an array of the public properties.
- */
- function getArrayCopy() {/**/}
-
- /** @param $position offset to seek to
- * @throw OutOfBoundsException if $position is invalid
- */
- function seek($position) {/**/}
-
- /** @return the number of elements in the array or the number of public
- * properties in the object.
- */
- function count() {/**/}
-
- /** @copydoc Iterator::rewind */
- function rewind() {/**/}
-
- /** @copydoc Iterator::valid */
- function valid() {/**/}
-
- /** @copydoc Iterator::current */
- function current() {/**/}
-
- /** @copydoc Iterator::key */
- function key() {/**/}
-
- /** @copydoc Iterator::next */
- function next() {/**/}
-}
-
-/** @ingroup SPL
- * @brief File info class
- * @since PHP 5.1.3
- */
-class SplFileInfo
-{
- /** Construct a file info object
- *
- * @param $file_name path or file name
- */
- function __construct($file_name) {/**/}
-
- /** @return the path part only.
- */
- function getPath() {/**/}
-
- /** @return the filename only.
- */
- function getFilename() {/**/}
-
- /** @return SplFileInfo created for the file
- * @param class_name name of class to instantiate
- * @see SplFileInfo::setInfoClass()
- */
- function getFileInfo(string class_name = NULL) {/**/}
-
- /** @return The current entries path and file name.
- */
- function getPathname() {/**/}
-
- /** @return SplFileInfo created for the path
- * @param class_name name of class to instantiate
- * @see SplFileInfo::setInfoClass()
- */
- function getPathInfo(string class_name = NULL) {/**/}
-
- /** @return The current entry's permissions.
- */
- function getPerms() {/**/}
-
- /** @return The current entry's inode.
- */
- function getInode() {/**/}
-
- /** @return The current entry's size in bytes .
- */
- function getSize() {/**/}
-
- /** @return The current entry's owner name.
- */
- function getOwner() {/**/}
-
- /** @return The current entry's group name.
- */
- function getGroup() {/**/}
-
- /** @return The current entry's last access time.
- */
- function getATime() {/**/}
-
- /** @return The current entry's last modification time.
- */
- function getMTime() {/**/}
-
- /** @return The current entry's last change time.
- */
- function getCTime() {/**/}
-
- /** @return The current entry's file type.
- */
- function getType() {/**/}
-
- /** @return Whether the current entry is writeable.
- */
- function isWritable() {/**/}
-
- /** @return Whether the current entry is readable.
- */
- function isReadable() {/**/}
-
- /** @return Whether the current entry is executable.
- */
- function isExecutable() {/**/}
-
- /** @return Whether the current entry is .
- */
- function isFile() {/**/}
-
- /** @return Whether the current entry is a directory.
- */
- function isDir() {/**/}
-
- /** @return whether the current entry is a link.
- */
- function isLink() {/**/}
-
- /** @return target of link.
- */
- function getLinkTarget() {/**/}
-
- /** @return The resolved path
- */
- function getRealPath() {/**/}
-
- /** @return getPathname()
- */
- function __toString() {/**/}
-
- /** Open the current file as a SplFileObject instance
- *
- * @param mode open mode
- * @param use_include_path whether to search include paths (don't use)
- * @param context resource context to passed to open function
- * @throw RuntimeException if file cannot be opened (e.g. insufficient
- * access rights).
- * @return The opened file as a SplFileObject instance
- *
- * @see SplFileObject
- * @see SplFileInfo::setFileClass()
- * @see file()
- */
- function openFile($mode = 'r', $use_include_path = false, $context = NULL) {/**/}
-
- /** @param class_name name of class used with openFile(). Must be derived
- * from SPLFileObject.
- */
- function setFileClass(string class_name = "SplFileObject") {/**/}
-
- /** @param class_name name of class used with getFileInfo(), getPathInfo().
- * Must be derived from SplFileInfo.
- */
- function setInfoClass(string class_name = "SplFileInfo") {/**/}
-}
-
-/** @ingroup SPL
- * @brief Directory iterator
- * @version 1.1
- * @since PHP 5.0
- */
-class DirectoryIterator extends SplFileInfo implements Iterator
-{
- /** Construct a directory iterator from a path-string.
- *
- * @param $path directory to iterate.
- */
- function __construct($path) {/**/}
-
- /** @copydoc Iterator::rewind */
- function rewind() {/**/}
-
- /** @copydoc Iterator::valid */
- function valid() {/**/}
-
- /** @return index of entry
- */
- function key() {/**/}
-
- /** @return $this
- */
- function current() {/**/}
-
- /** @copydoc Iterator::next */
- function next() {/**/}
-
- /** @return Whether the current entry is either '.' or '..'.
- */
- function isDot() {/**/}
-
- /** @return whether the current entry is a link.
- */
- function isLink() {/**/}
-
- /** @return getFilename()
- */
- function __toString() {/**/}
-}
-
-/** @ingroup SPL
- * @brief recursive directory iterator
- * @version 1.1
- * @since PHP 5.0
- */
-class RecursiveDirectoryIterator extends DirectoryIterator implements RecursiveIterator
-{
- const CURRENT_AS_FILEINFO 0x00000000; /* make RecursiveDirectoryTree::current() return SplFileInfo */
- const CURRENT_AS_SELF 0x00000010; /* make RecursiveDirectoryTree::current() return getSelf() */
- const CURRENT_AS_PATHNAME 0x00000020; /* make RecursiveDirectoryTree::current() return getPathname() */
-
- const KEY_AS_PATHNAME 0x00000000; /* make RecursiveDirectoryTree::key() return getPathname() */
- const KEY_AS_FILENAME 0x00000100; /* make RecursiveDirectoryTree::key() return getFilename() */
-
- const NEW_CURRENT_AND_KEY 0x00000100; /* CURRENT_AS_FILEINFO + KEY_AS_FILENAME */
-
- /** Construct a directory iterator from a path-string.
- *
- * @param $path directory to iterate.
- * @param $flags open flags
- * - CURRENT_AS_FILEINFO
- * - CURRENT_AS_SELF
- * - CURRENT_AS_PATHNAME
- * - KEY_AS_PATHNAME
- * - KEY_AS_FILENAME
- * - NEW_CURRENT_AND_KEY
- */
- function __construct($path, $flags = 0) {/**/}
-
- /** @return getPathname() or getFilename() depending on flags
- */
- function key() {/**/}
-
- /** @return getFilename() or getFileInfo() depending on flags
- */
- function current() {/**/}
-
- /** @return whether the current is a directory (not '.' or '..').
- */
- function hasChildren() {/**/}
-
- /** @return a RecursiveDirectoryIterator for the current entry.
- */
- function getChildren() {/**/}
-
- /** @return sub path only (without main path)
- */
- function getSubPath() {/**/}
-
- /** @return the current sub path
- */
- function getSubPathname() {/**/}
-}
-
-/** @ingroup SPL
- * @brief recursive SimpleXML_Element iterator
- * @since PHP 5.0
- *
- * The SimpleXMLIterator implements the RecursiveIterator interface. This
- * allows iteration over all elements using foreach or an appropriate while
- * construct, just like SimpleXMLElement does. When using the foreach construct,
- * you will also iterate over the subelements. For every element which
- * has subelements, hasChildren() returns true. This will trigger a call to
- * getChildren() which returns the iterator for that sub element.
- */
-class SimpleXMLIterator extends SimpleXMLElement implements RecursiveIterator, Countable
-{
- /** @return whether the current node has sub nodes.
- */
- function hasChildren() {/**/}
-
- /** @return a SimpleXMLIterator for the current node.
- */
- function getChildren() {/**/}
-
- /** @return number of elements/attributes seen with foreach()
- */
- function count() {/**/}
-
- /** @copydoc Iterator::rewind */
- function rewind() {/**/}
-
- /** @copydoc Iterator::valid */
- function valid() {/**/}
-
- /** @copydoc Iterator::current */
- function current() {/**/}
-
- /** @copydoc Iterator::key */
- function key() {/**/}
-
- /** @copydoc Iterator::next */
- function next() {/**/}
-}
-
-/** @ingroup SPL
- * @brief Observer of the observer pattern
- * @since PHP 5.1
- *
- * For a detailed explanation see Observer pattern in
- * <em>
- * Gamma, Helm, Johnson, Vlissides<br />
- * Design Patterns
- * </em>
- */
-interface SplObserver
-{
- /** Called from the subject (i.e. when it's value has changed).
- * @param $subject the callee
- */
- function update(SplSubject $subject);
-}
-
-/** @ingroup SPL
- * @brief Subject to the observer pattern
- * @since PHP 5.1
- * @see Observer
- */
-interface SplSubject
-{
- /** @param $observer new observer to attach
- */
- function attach(SplObserver $observer);
-
- /** @param $observer existing observer to detach
- * @note a non attached observer shouldn't result in a warning or similar
- */
- function detach(SplObserver $observer);
-
- /** Notify all observers
- */
- function notify();
-}
-
-?>
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 9b11782147..90861b49c6 100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -206,7 +206,6 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval *
while (parent) {
if (parent == spl_ce_ArrayIterator || parent == spl_ce_RecursiveArrayIterator) {
intern->std.handlers = &spl_handler_ArrayIterator;
- class_type->get_iterator = spl_array_get_iterator;
break;
} else if (parent == spl_ce_ArrayObject) {
intern->std.handlers = &spl_handler_ArrayObject;
@@ -243,19 +242,21 @@ static zend_object *spl_array_object_new_ex(zend_class_entry *class_type, zval *
/* Cache iterator functions if ArrayIterator or derived. Check current's */
/* cache since only current is always required */
if (intern->std.handlers == &spl_handler_ArrayIterator) {
- if (!class_type->iterator_funcs_ptr->zf_current) {
- class_type->iterator_funcs_ptr->zf_rewind = zend_hash_str_find_ptr(&class_type->function_table, "rewind", sizeof("rewind") - 1);
- class_type->iterator_funcs_ptr->zf_valid = zend_hash_str_find_ptr(&class_type->function_table, "valid", sizeof("valid") - 1);
- class_type->iterator_funcs_ptr->zf_key = zend_hash_str_find_ptr(&class_type->function_table, "key", sizeof("key") - 1);
- class_type->iterator_funcs_ptr->zf_current = zend_hash_str_find_ptr(&class_type->function_table, "current", sizeof("current") - 1);
- class_type->iterator_funcs_ptr->zf_next = zend_hash_str_find_ptr(&class_type->function_table, "next", sizeof("next") - 1);
+ zend_class_iterator_funcs *funcs_ptr = class_type->iterator_funcs_ptr;
+
+ if (!funcs_ptr->zf_current) {
+ funcs_ptr->zf_rewind = zend_hash_str_find_ptr(&class_type->function_table, "rewind", sizeof("rewind") - 1);
+ funcs_ptr->zf_valid = zend_hash_str_find_ptr(&class_type->function_table, "valid", sizeof("valid") - 1);
+ funcs_ptr->zf_key = zend_hash_str_find_ptr(&class_type->function_table, "key", sizeof("key") - 1);
+ funcs_ptr->zf_current = zend_hash_str_find_ptr(&class_type->function_table, "current", sizeof("current") - 1);
+ funcs_ptr->zf_next = zend_hash_str_find_ptr(&class_type->function_table, "next", sizeof("next") - 1);
}
if (inherited) {
- if (class_type->iterator_funcs_ptr->zf_rewind->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_REWIND;
- if (class_type->iterator_funcs_ptr->zf_valid->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_VALID;
- if (class_type->iterator_funcs_ptr->zf_key->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_KEY;
- if (class_type->iterator_funcs_ptr->zf_current->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_CURRENT;
- if (class_type->iterator_funcs_ptr->zf_next->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_NEXT;
+ if (funcs_ptr->zf_rewind->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_REWIND;
+ if (funcs_ptr->zf_valid->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_VALID;
+ if (funcs_ptr->zf_key->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_KEY;
+ if (funcs_ptr->zf_current->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_CURRENT;
+ if (funcs_ptr->zf_next->common.scope != parent) intern->ar_flags |= SPL_ARRAY_OVERLOADED_NEXT;
}
}
@@ -697,23 +698,6 @@ static int spl_array_has_dimension(zval *object, zval *offset, int check_empty)
return spl_array_has_dimension_ex(1, object, offset, check_empty);
} /* }}} */
-/* {{{ spl_array_object_verify_pos_ex */
-static inline int spl_array_object_verify_pos_ex(spl_array_object *object, HashTable *ht, const char *msg_prefix)
-{
- if (!ht) {
- php_error_docref(NULL, E_NOTICE, "%sArray was modified outside object and is no longer an array", msg_prefix);
- return FAILURE;
- }
-
- return SUCCESS;
-} /* }}} */
-
-/* {{{ spl_array_object_verify_pos */
-static inline int spl_array_object_verify_pos(spl_array_object *object, HashTable *ht)
-{
- return spl_array_object_verify_pos_ex(object, ht, "");
-} /* }}} */
-
/* {{{ proto bool ArrayObject::offsetExists(mixed $index)
proto bool ArrayIterator::offsetExists(mixed $index)
Returns whether the requested $index exists. */
@@ -723,7 +707,7 @@ SPL_METHOD(Array, offsetExists)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &index) == FAILURE) {
return;
}
- RETURN_BOOL(spl_array_has_dimension_ex(0, getThis(), index, 2));
+ RETURN_BOOL(spl_array_has_dimension_ex(0, ZEND_THIS, index, 2));
} /* }}} */
/* {{{ proto mixed ArrayObject::offsetGet(mixed $index)
@@ -735,7 +719,7 @@ SPL_METHOD(Array, offsetGet)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &index) == FAILURE) {
return;
}
- value = spl_array_read_dimension_ex(0, getThis(), index, BP_VAR_R, return_value);
+ value = spl_array_read_dimension_ex(0, ZEND_THIS, index, BP_VAR_R, return_value);
if (value != return_value) {
ZVAL_COPY_DEREF(return_value, value);
}
@@ -750,18 +734,12 @@ SPL_METHOD(Array, offsetSet)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &index, &value) == FAILURE) {
return;
}
- spl_array_write_dimension_ex(0, getThis(), index, value);
+ spl_array_write_dimension_ex(0, ZEND_THIS, index, value);
} /* }}} */
void spl_array_iterator_append(zval *object, zval *append_value) /* {{{ */
{
spl_array_object *intern = Z_SPLARRAY_P(object);
- HashTable *aht = spl_array_get_hash_table(intern);
-
- if (!aht) {
- php_error_docref(NULL, E_NOTICE, "Array was modified outside object and is no longer an array");
- return;
- }
if (spl_array_is_object(intern)) {
zend_throw_error(NULL, "Cannot append properties to objects, use %s::offsetSet() instead", ZSTR_VAL(Z_OBJCE_P(object)->name));
@@ -781,7 +759,7 @@ SPL_METHOD(Array, append)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &value) == FAILURE) {
return;
}
- spl_array_iterator_append(getThis(), value);
+ spl_array_iterator_append(ZEND_THIS, value);
} /* }}} */
/* {{{ proto void ArrayObject::offsetUnset(mixed $index)
@@ -793,7 +771,7 @@ SPL_METHOD(Array, offsetUnset)
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &index) == FAILURE) {
return;
}
- spl_array_unset_dimension_ex(0, getThis(), index);
+ spl_array_unset_dimension_ex(0, ZEND_THIS, index);
} /* }}} */
/* {{{ proto array ArrayObject::getArrayCopy()
@@ -801,24 +779,47 @@ SPL_METHOD(Array, offsetUnset)
Return a copy of the contained array */
SPL_METHOD(Array, getArrayCopy)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
RETURN_ARR(zend_array_dup(spl_array_get_hash_table(intern)));
} /* }}} */
-static HashTable *spl_array_get_properties(zval *object) /* {{{ */
+static HashTable *spl_array_get_properties_for(zval *object, zend_prop_purpose purpose) /* {{{ */
{
spl_array_object *intern = Z_SPLARRAY_P(object);
+ HashTable *ht;
+ zend_bool dup;
if (intern->ar_flags & SPL_ARRAY_STD_PROP_LIST) {
- if (!intern->std.properties) {
- rebuild_object_properties(&intern->std);
- }
- return intern->std.properties;
+ return zend_std_get_properties_for(object, purpose);
}
- return spl_array_get_hash_table(intern);
+ /* We are supposed to be the only owner of the internal hashtable.
+ * The "dup" flag decides whether this is a "long-term" use where
+ * we need to duplicate, or a "temporary" one, where we can expect
+ * that no operations on the ArrayObject will be performed in the
+ * meantime. */
+ switch (purpose) {
+ case ZEND_PROP_PURPOSE_ARRAY_CAST:
+ dup = 1;
+ break;
+ case ZEND_PROP_PURPOSE_VAR_EXPORT:
+ case ZEND_PROP_PURPOSE_JSON:
+ case _ZEND_PROP_PURPOSE_ARRAY_KEY_EXISTS:
+ dup = 0;
+ break;
+ default:
+ return zend_std_get_properties_for(object, purpose);
+ }
+
+ ht = spl_array_get_hash_table(intern);
+ if (dup) {
+ ht = zend_array_dup(ht);
+ } else {
+ GC_ADDREF(ht);
+ }
+ return ht;
} /* }}} */
static HashTable* spl_array_get_debug_info(zval *obj, int *is_temp) /* {{{ */
@@ -876,16 +877,16 @@ static zval *spl_array_read_property(zval *object, zval *member, int type, void
return zend_std_read_property(object, member, type, cache_slot, rv);
} /* }}} */
-static void spl_array_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */
+static zval *spl_array_write_property(zval *object, zval *member, zval *value, void **cache_slot) /* {{{ */
{
spl_array_object *intern = Z_SPLARRAY_P(object);
if ((intern->ar_flags & SPL_ARRAY_ARRAY_AS_PROPS) != 0
&& !zend_std_has_property(object, member, ZEND_PROPERTY_EXISTS, NULL)) {
spl_array_write_dimension(object, member, value);
- return;
+ return value;
}
- zend_std_write_property(object, member, value, cache_slot);
+ return zend_std_write_property(object, member, value, cache_slot);
} /* }}} */
static zval *spl_array_get_property_ptr_ptr(zval *object, zval *member, int type, void **cache_slot) /* {{{ */
@@ -1014,10 +1015,6 @@ static int spl_array_it_valid(zend_object_iterator *iter) /* {{{ */
if (object->ar_flags & SPL_ARRAY_OVERLOADED_VALID) {
return zend_user_it_valid(iter);
} else {
- if (spl_array_object_verify_pos_ex(object, aht, "ArrayIterator::valid(): ") == FAILURE) {
- return FAILURE;
- }
-
return zend_hash_has_more_elements_ex(aht, spl_array_get_pos_ptr(aht, object));
}
}
@@ -1048,11 +1045,7 @@ static void spl_array_it_get_current_key(zend_object_iterator *iter, zval *key)
if (object->ar_flags & SPL_ARRAY_OVERLOADED_KEY) {
zend_user_it_get_current_key(iter, key);
} else {
- if (spl_array_object_verify_pos_ex(object, aht, "ArrayIterator::current(): ") == FAILURE) {
- ZVAL_NULL(key);
- } else {
- zend_hash_get_current_key_zval_ex(aht, key, spl_array_get_pos_ptr(aht, object));
- }
+ zend_hash_get_current_key_zval_ex(aht, key, spl_array_get_pos_ptr(aht, object));
}
}
/* }}} */
@@ -1066,11 +1059,6 @@ static void spl_array_it_move_forward(zend_object_iterator *iter) /* {{{ */
zend_user_it_move_forward(iter);
} else {
zend_user_it_invalidate_current(iter);
- if (!aht) {
- php_error_docref(NULL, E_NOTICE, "ArrayIterator::current(): Array was modified outside object and is no longer an array");
- return;
- }
-
spl_array_next_ex(object, aht);
}
}
@@ -1080,11 +1068,6 @@ static void spl_array_rewind(spl_array_object *intern) /* {{{ */
{
HashTable *aht = spl_array_get_hash_table(intern);
- if (!aht) {
- php_error_docref(NULL, E_NOTICE, "ArrayIterator::rewind(): Array was modified outside object and is no longer an array");
- return;
- }
-
if (intern->ht_iter == (uint32_t)-1) {
spl_array_get_pos_ptr(aht, intern);
} else {
@@ -1180,7 +1163,8 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object,
zend_iterator_init(&iterator->it);
- ZVAL_COPY(&iterator->it.data, object);
+ Z_ADDREF_P(object);
+ ZVAL_OBJ(&iterator->it.data, Z_OBJ_P(object));
iterator->it.funcs = &spl_array_it_funcs;
iterator->ce = ce;
ZVAL_UNDEF(&iterator->value);
@@ -1193,7 +1177,7 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object,
Constructs a new array object from an array or object. */
SPL_METHOD(Array, __construct)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern;
zval *array;
zend_long ar_flags = 0;
@@ -1223,7 +1207,7 @@ SPL_METHOD(Array, __construct)
Constructs a new array iterator from an array or object. */
SPL_METHOD(ArrayIterator, __construct)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern;
zval *array;
zend_long ar_flags = 0;
@@ -1248,7 +1232,7 @@ SPL_METHOD(ArrayIterator, __construct)
Set the class used in getIterator. */
SPL_METHOD(Array, setIteratorClass)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
zend_class_entry * ce_get_iterator = spl_ce_Iterator;
@@ -1264,7 +1248,7 @@ SPL_METHOD(Array, setIteratorClass)
Get the class used in getIterator. */
SPL_METHOD(Array, getIteratorClass)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
if (zend_parse_parameters_none() == FAILURE) {
@@ -1280,7 +1264,7 @@ SPL_METHOD(Array, getIteratorClass)
Get flags */
SPL_METHOD(Array, getFlags)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
if (zend_parse_parameters_none() == FAILURE) {
@@ -1295,7 +1279,7 @@ SPL_METHOD(Array, getFlags)
Set flags */
SPL_METHOD(Array, setFlags)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
zend_long ar_flags = 0;
@@ -1307,11 +1291,11 @@ SPL_METHOD(Array, setFlags)
}
/* }}} */
-/* {{{ proto Array|Object ArrayObject::exchangeArray(Array|Object ar = array())
+/* {{{ proto Array|Object ArrayObject::exchangeArray(Array|Object input = array())
Replace the referenced array or object with a new one and return the old one (right now copy - to be changed) */
SPL_METHOD(Array, exchangeArray)
{
- zval *object = getThis(), *array;
+ zval *object = ZEND_THIS, *array;
spl_array_object *intern = Z_SPLARRAY_P(object);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &array) == FAILURE) {
@@ -1332,19 +1316,13 @@ SPL_METHOD(Array, exchangeArray)
Create a new iterator from a ArrayObject instance */
SPL_METHOD(Array, getIterator)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
- HashTable *aht = spl_array_get_hash_table(intern);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- if (!aht) {
- php_error_docref(NULL, E_NOTICE, "Array was modified outside object and is no longer an array");
- return;
- }
-
ZVAL_OBJ(return_value, spl_array_object_new_ex(intern->ce_get_iterator, object, 0));
}
/* }}} */
@@ -1353,7 +1331,7 @@ SPL_METHOD(Array, getIterator)
Rewind array back to the start */
SPL_METHOD(Array, rewind)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
if (zend_parse_parameters_none() == FAILURE) {
@@ -1369,7 +1347,7 @@ SPL_METHOD(Array, rewind)
SPL_METHOD(Array, seek)
{
zend_long opos, position;
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
HashTable *aht = spl_array_get_hash_table(intern);
int result;
@@ -1378,11 +1356,6 @@ SPL_METHOD(Array, seek)
return;
}
- if (!aht) {
- php_error_docref(NULL, E_NOTICE, "Array was modified outside object and is no longer an array");
- return;
- }
-
opos = position;
if (position >= 0) { /* negative values are not supported */
@@ -1398,32 +1371,24 @@ SPL_METHOD(Array, seek)
zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0, "Seek position " ZEND_LONG_FMT " is out of range", opos);
} /* }}} */
-static int spl_array_object_count_elements_helper(spl_array_object *intern, zend_long *count) /* {{{ */
+static zend_long spl_array_object_count_elements_helper(spl_array_object *intern) /* {{{ */
{
HashTable *aht = spl_array_get_hash_table(intern);
- HashPosition pos, *pos_ptr;
-
- if (!aht) {
- php_error_docref(NULL, E_NOTICE, "Array was modified outside object and is no longer an array");
- *count = 0;
- return FAILURE;
- }
-
if (spl_array_is_object(intern)) {
- /* We need to store the 'pos' since we'll modify it in the functions
- * we're going to call and which do not support 'pos' as parameter. */
- pos_ptr = spl_array_get_pos_ptr(aht, intern);
- pos = *pos_ptr;
- *count = 0;
- spl_array_rewind(intern);
- while (*pos_ptr < aht->nNumUsed && spl_array_next(intern) == SUCCESS) {
- (*count)++;
- }
- *pos_ptr = pos;
- return SUCCESS;
+ zend_long count = 0;
+ zend_string *key;
+ zval *val;
+ /* Count public/dynamic properties */
+ ZEND_HASH_FOREACH_STR_KEY_VAL(aht, key, val) {
+ if (Z_TYPE_P(val) == IS_INDIRECT) {
+ if (Z_TYPE_P(Z_INDIRECT_P(val)) == IS_UNDEF) continue;
+ if (key && ZSTR_VAL(key)[0] == '\0') continue;
+ }
+ count++;
+ } ZEND_HASH_FOREACH_END();
+ return count;
} else {
- *count = zend_hash_num_elements(aht);
- return SUCCESS;
+ return zend_hash_num_elements(aht);
}
} /* }}} */
@@ -1442,7 +1407,8 @@ int spl_array_object_count_elements(zval *object, zend_long *count) /* {{{ */
*count = 0;
return FAILURE;
}
- return spl_array_object_count_elements_helper(intern, count);
+ *count = spl_array_object_count_elements_helper(intern);
+ return SUCCESS;
} /* }}} */
/* {{{ proto int ArrayObject::count()
@@ -1450,21 +1416,18 @@ int spl_array_object_count_elements(zval *object, zend_long *count) /* {{{ */
Return the number of elements in the Iterator. */
SPL_METHOD(Array, count)
{
- zend_long count;
- spl_array_object *intern = Z_SPLARRAY_P(getThis());
+ spl_array_object *intern = Z_SPLARRAY_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- spl_array_object_count_elements_helper(intern, &count);
-
- RETURN_LONG(count);
+ RETURN_LONG(spl_array_object_count_elements_helper(intern));
} /* }}} */
static void spl_array_method(INTERNAL_FUNCTION_PARAMETERS, char *fname, int fname_len, int use_arg) /* {{{ */
{
- spl_array_object *intern = Z_SPLARRAY_P(getThis());
+ spl_array_object *intern = Z_SPLARRAY_P(ZEND_THIS);
HashTable *aht = spl_array_get_hash_table(intern);
zval function_name, params[2], *arg = NULL;
@@ -1508,7 +1471,8 @@ exit:
} else {
GC_DELREF(aht);
}
- efree(Z_REF(params[0]));
+ ZVAL_NULL(Z_REFVAL(params[0]));
+ zval_ptr_dtor(&params[0]);
zend_string_free(Z_STR(function_name));
}
} /* }}} */
@@ -1553,7 +1517,7 @@ SPL_ARRAY_METHOD(Array, natcasesort, SPL_ARRAY_METHOD_NO_ARG) /* }}} */
Return current array entry */
SPL_METHOD(Array, current)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
zval *entry;
HashTable *aht = spl_array_get_hash_table(intern);
@@ -1562,10 +1526,6 @@ SPL_METHOD(Array, current)
return;
}
- if (spl_array_object_verify_pos(intern, aht) == FAILURE) {
- return;
- }
-
if ((entry = zend_hash_get_current_data_ex(aht, spl_array_get_pos_ptr(aht, intern))) == NULL) {
return;
}
@@ -1587,7 +1547,7 @@ SPL_METHOD(Array, key)
return;
}
- spl_array_iterator_key(getThis(), return_value);
+ spl_array_iterator_key(ZEND_THIS, return_value);
} /* }}} */
void spl_array_iterator_key(zval *object, zval *return_value) /* {{{ */
@@ -1595,10 +1555,6 @@ void spl_array_iterator_key(zval *object, zval *return_value) /* {{{ */
spl_array_object *intern = Z_SPLARRAY_P(object);
HashTable *aht = spl_array_get_hash_table(intern);
- if (spl_array_object_verify_pos(intern, aht) == FAILURE) {
- return;
- }
-
zend_hash_get_current_key_zval_ex(aht, return_value, spl_array_get_pos_ptr(aht, intern));
}
/* }}} */
@@ -1607,7 +1563,7 @@ void spl_array_iterator_key(zval *object, zval *return_value) /* {{{ */
Move to next entry */
SPL_METHOD(Array, next)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
HashTable *aht = spl_array_get_hash_table(intern);
@@ -1615,10 +1571,6 @@ SPL_METHOD(Array, next)
return;
}
- if (spl_array_object_verify_pos(intern, aht) == FAILURE) {
- return;
- }
-
spl_array_next_ex(intern, aht);
}
/* }}} */
@@ -1627,7 +1579,7 @@ SPL_METHOD(Array, next)
Check whether array contains more entries */
SPL_METHOD(Array, valid)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
HashTable *aht = spl_array_get_hash_table(intern);
@@ -1635,11 +1587,7 @@ SPL_METHOD(Array, valid)
return;
}
- if (spl_array_object_verify_pos(intern, aht) == FAILURE) {
- RETURN_FALSE;
- } else {
- RETURN_BOOL(zend_hash_has_more_elements_ex(aht, spl_array_get_pos_ptr(aht, intern)) == SUCCESS);
- }
+ RETURN_BOOL(zend_hash_has_more_elements_ex(aht, spl_array_get_pos_ptr(aht, intern)) == SUCCESS);
}
/* }}} */
@@ -1647,7 +1595,7 @@ SPL_METHOD(Array, valid)
Check whether current element has children (e.g. is an array) */
SPL_METHOD(Array, hasChildren)
{
- zval *object = getThis(), *entry;
+ zval *object = ZEND_THIS, *entry;
spl_array_object *intern = Z_SPLARRAY_P(object);
HashTable *aht = spl_array_get_hash_table(intern);
@@ -1655,10 +1603,6 @@ SPL_METHOD(Array, hasChildren)
return;
}
- if (spl_array_object_verify_pos(intern, aht) == FAILURE) {
- RETURN_FALSE;
- }
-
if ((entry = zend_hash_get_current_data_ex(aht, spl_array_get_pos_ptr(aht, intern))) == NULL) {
RETURN_FALSE;
}
@@ -1676,7 +1620,7 @@ SPL_METHOD(Array, hasChildren)
Create a sub iterator for the current element (same class as $this) */
SPL_METHOD(Array, getChildren)
{
- zval *object = getThis(), *entry, flags;
+ zval *object = ZEND_THIS, *entry, flags;
spl_array_object *intern = Z_SPLARRAY_P(object);
HashTable *aht = spl_array_get_hash_table(intern);
@@ -1684,10 +1628,6 @@ SPL_METHOD(Array, getChildren)
return;
}
- if (spl_array_object_verify_pos(intern, aht) == FAILURE) {
- return;
- }
-
if ((entry = zend_hash_get_current_data_ex(aht, spl_array_get_pos_ptr(aht, intern))) == NULL) {
return;
}
@@ -1701,7 +1641,7 @@ SPL_METHOD(Array, getChildren)
if ((intern->ar_flags & SPL_ARRAY_CHILD_ARRAYS_ONLY) != 0) {
return;
}
- if (instanceof_function(Z_OBJCE_P(entry), Z_OBJCE_P(getThis()))) {
+ if (instanceof_function(Z_OBJCE_P(entry), Z_OBJCE_P(ZEND_THIS))) {
ZVAL_OBJ(return_value, Z_OBJ_P(entry));
Z_ADDREF_P(return_value);
return;
@@ -1709,7 +1649,7 @@ SPL_METHOD(Array, getChildren)
}
ZVAL_LONG(&flags, intern->ar_flags);
- spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), return_value, entry, &flags);
+ spl_instantiate_arg_ex2(Z_OBJCE_P(ZEND_THIS), return_value, entry, &flags);
}
/* }}} */
@@ -1717,9 +1657,8 @@ SPL_METHOD(Array, getChildren)
Serialize the object */
SPL_METHOD(Array, serialize)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
- HashTable *aht = spl_array_get_hash_table(intern);
zval members, flags;
php_serialize_data_t var_hash;
smart_str buf = {0};
@@ -1728,11 +1667,6 @@ SPL_METHOD(Array, serialize)
return;
}
- if (!aht) {
- php_error_docref(NULL, E_NOTICE, "Array was modified outside object and is no longer an array");
- return;
- }
-
PHP_VAR_SERIALIZE_INIT(var_hash);
ZVAL_LONG(&flags, (intern->ar_flags & SPL_ARRAY_CLONE_MASK));
@@ -1771,7 +1705,7 @@ SPL_METHOD(Array, serialize)
*/
SPL_METHOD(Array, unserialize)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_array_object *intern = Z_SPLARRAY_P(object);
char *buf;
@@ -1880,6 +1814,75 @@ outexcept:
} /* }}} */
+/* {{{ proto array ArrayObject::__serialize() */
+SPL_METHOD(Array, __serialize)
+{
+ spl_array_object *intern = Z_SPLARRAY_P(ZEND_THIS);
+ zval tmp;
+
+ if (zend_parse_parameters_none_throw() == FAILURE) {
+ return;
+ }
+
+ array_init(return_value);
+
+ /* flags */
+ ZVAL_LONG(&tmp, (intern->ar_flags & SPL_ARRAY_CLONE_MASK));
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
+
+ /* storage */
+ if (intern->ar_flags & SPL_ARRAY_IS_SELF) {
+ ZVAL_NULL(&tmp);
+ } else {
+ ZVAL_COPY(&tmp, &intern->array);
+ }
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
+
+ /* members */
+ ZVAL_ARR(&tmp, zend_std_get_properties(ZEND_THIS));
+ Z_TRY_ADDREF(tmp);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
+}
+/* }}} */
+
+
+/* {{{ proto void ArrayObject::__unserialize(array data) */
+SPL_METHOD(Array, __unserialize)
+{
+ spl_array_object *intern = Z_SPLARRAY_P(ZEND_THIS);
+ HashTable *data;
+ zval *flags_zv, *storage_zv, *members_zv;
+ zend_long flags;
+
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "h", &data) == FAILURE) {
+ return;
+ }
+
+ flags_zv = zend_hash_index_find(data, 0);
+ storage_zv = zend_hash_index_find(data, 1);
+ members_zv = zend_hash_index_find(data, 2);
+ if (!flags_zv || !storage_zv || !members_zv ||
+ Z_TYPE_P(flags_zv) != IS_LONG || Z_TYPE_P(members_zv) != IS_ARRAY) {
+ zend_throw_exception(spl_ce_UnexpectedValueException,
+ "Incomplete or ill-typed serialization data", 0);
+ return;
+ }
+
+ flags = Z_LVAL_P(flags_zv);
+ intern->ar_flags &= ~SPL_ARRAY_CLONE_MASK;
+ intern->ar_flags |= flags & SPL_ARRAY_CLONE_MASK;
+
+ if (flags & SPL_ARRAY_IS_SELF) {
+ zval_ptr_dtor(&intern->array);
+ ZVAL_UNDEF(&intern->array);
+ } else {
+ spl_array_set_array(ZEND_THIS, intern, storage_zv, 0L, 1);
+ }
+
+ object_properties_load(&intern->std, Z_ARRVAL_P(members_zv));
+}
+/* }}} */
+
/* {{{ arginfo and function table */
ZEND_BEGIN_ARG_INFO_EX(arginfo_array___construct, 0, 0, 0)
ZEND_ARG_INFO(0, input)
@@ -1890,7 +1893,7 @@ ZEND_END_ARG_INFO()
/* ArrayIterator::__construct and ArrayObject::__construct have different signatures */
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_iterator___construct, 0, 0, 0)
ZEND_ARG_INFO(0, array)
- ZEND_ARG_INFO(0, ar_flags)
+ ZEND_ARG_INFO(0, flags)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_array_offsetGet, 0, 0, 1)
@@ -1911,7 +1914,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_array_seek, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_array_exchangeArray, 0)
- ZEND_ARG_INFO(0, array)
+ ZEND_ARG_INFO(0, input)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_array_setFlags, 0)
@@ -1952,6 +1955,8 @@ static const zend_function_entry spl_funcs_ArrayObject[] = {
SPL_ME(Array, natcasesort, arginfo_array_void, ZEND_ACC_PUBLIC)
SPL_ME(Array, unserialize, arginfo_array_unserialize, ZEND_ACC_PUBLIC)
SPL_ME(Array, serialize, arginfo_array_void, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, __unserialize, arginfo_array_unserialize, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, __serialize, arginfo_array_void, ZEND_ACC_PUBLIC)
/* ArrayObject specific */
SPL_ME(Array, getIterator, arginfo_array_void, ZEND_ACC_PUBLIC)
SPL_ME(Array, exchangeArray, arginfo_array_exchangeArray, ZEND_ACC_PUBLIC)
@@ -1979,6 +1984,8 @@ static const zend_function_entry spl_funcs_ArrayIterator[] = {
SPL_ME(Array, natcasesort, arginfo_array_void, ZEND_ACC_PUBLIC)
SPL_ME(Array, unserialize, arginfo_array_unserialize, ZEND_ACC_PUBLIC)
SPL_ME(Array, serialize, arginfo_array_void, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, __unserialize, arginfo_array_unserialize, ZEND_ACC_PUBLIC)
+ SPL_ME(Array, __serialize, arginfo_array_void, ZEND_ACC_PUBLIC)
/* ArrayIterator specific */
SPL_ME(Array, rewind, arginfo_array_void, ZEND_ACC_PUBLIC)
SPL_ME(Array, current, arginfo_array_void, ZEND_ACC_PUBLIC)
@@ -2015,7 +2022,7 @@ PHP_MINIT_FUNCTION(spl_array)
spl_handler_ArrayObject.has_dimension = spl_array_has_dimension;
spl_handler_ArrayObject.count_elements = spl_array_object_count_elements;
- spl_handler_ArrayObject.get_properties = spl_array_get_properties;
+ spl_handler_ArrayObject.get_properties_for = spl_array_get_properties_for;
spl_handler_ArrayObject.get_debug_info = spl_array_get_debug_info;
spl_handler_ArrayObject.get_gc = spl_array_get_gc;
spl_handler_ArrayObject.read_property = spl_array_read_property;
@@ -2036,6 +2043,8 @@ PHP_MINIT_FUNCTION(spl_array)
REGISTER_SPL_IMPLEMENTS(ArrayIterator, Countable);
memcpy(&spl_handler_ArrayIterator, &spl_handler_ArrayObject, sizeof(zend_object_handlers));
spl_ce_ArrayIterator->get_iterator = spl_array_get_iterator;
+ spl_ce_ArrayIterator->ce_flags |= ZEND_ACC_REUSE_GET_ITERATOR;
+
REGISTER_SPL_CLASS_CONST_LONG(ArrayObject, "STD_PROP_LIST", SPL_ARRAY_STD_PROP_LIST);
REGISTER_SPL_CLASS_CONST_LONG(ArrayObject, "ARRAY_AS_PROPS", SPL_ARRAY_ARRAY_AS_PROPS);
@@ -2046,18 +2055,10 @@ PHP_MINIT_FUNCTION(spl_array)
REGISTER_SPL_SUB_CLASS_EX(RecursiveArrayIterator, ArrayIterator, spl_array_object_new, spl_funcs_RecursiveArrayIterator);
REGISTER_SPL_IMPLEMENTS(RecursiveArrayIterator, RecursiveIterator);
spl_ce_RecursiveArrayIterator->get_iterator = spl_array_get_iterator;
+ spl_ce_RecursiveArrayIterator->ce_flags |= ZEND_ACC_REUSE_GET_ITERATOR;
REGISTER_SPL_CLASS_CONST_LONG(RecursiveArrayIterator, "CHILD_ARRAYS_ONLY", SPL_ARRAY_CHILD_ARRAYS_ONLY);
return SUCCESS;
}
/* }}} */
-
-/*
- * 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_array.h b/ext/spl/spl_array.h
index 0ffaeb9ae1..ed5dec3e62 100644
--- a/ext/spl/spl_array.h
+++ b/ext/spl/spl_array.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -33,12 +33,3 @@ extern void spl_array_iterator_append(zval *object, zval *append_value);
extern void spl_array_iterator_key(zval *object, zval *return_value);
#endif /* SPL_ARRAY_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/spl_directory.c b/ext/spl/spl_directory.c
index 7a91054fc4..691ae9b8d0 100644
--- a/ext/spl/spl_directory.c
+++ b/ext/spl/spl_directory.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -189,7 +189,7 @@ PHPAPI char* spl_filesystem_object_get_path(spl_filesystem_object *intern, size_
#ifdef HAVE_GLOB
if (intern->type == SPL_FS_DIR) {
if (php_stream_is(intern->u.dir.dirp ,&php_glob_stream_ops)) {
- return php_glob_stream_get_path(intern->u.dir.dirp, 0, len);
+ return php_glob_stream_get_path(intern->u.dir.dirp, len);
}
}
#endif
@@ -331,7 +331,7 @@ static int spl_filesystem_file_open(spl_filesystem_object *intern, int use_inclu
intern->u.file.delimiter = ',';
intern->u.file.enclosure = '"';
- intern->u.file.escape = '\\';
+ intern->u.file.escape = (unsigned char) '\\';
intern->u.file.func_getCurr = zend_hash_str_find_ptr(&intern->std.ce->function_table, "getcurrentline", sizeof("getcurrentline") - 1);
@@ -618,7 +618,7 @@ static HashTable *spl_filesystem_object_get_debug_info(zval *object, int *is_tem
pnstr = spl_gen_private_prop_name(spl_ce_SplFileInfo, "pathName", sizeof("pathName")-1);
path = spl_filesystem_object_get_pathname(intern, &path_len);
- ZVAL_STRINGL(&tmp, path, path_len);
+ ZVAL_STRINGL(&tmp, path ? path : "", path_len);
zend_symtable_update(rv, pnstr, &tmp);
zend_string_release_ex(pnstr, 0);
@@ -729,9 +729,9 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, zend_long cto
return;
}
- intern = Z_SPLFILESYSTEM_P(getThis());
+ intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (intern->_path) {
- /* object is alreay initialized */
+ /* object is already initialized */
zend_restore_error_handling(&error_handling);
php_error_docref(NULL, E_WARNING, "Directory object is already initialized");
return;
@@ -767,7 +767,7 @@ SPL_METHOD(DirectoryIterator, __construct)
Rewind dir back to the start */
SPL_METHOD(DirectoryIterator, rewind)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -785,7 +785,7 @@ SPL_METHOD(DirectoryIterator, rewind)
Return current dir entry */
SPL_METHOD(DirectoryIterator, key)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -806,7 +806,7 @@ SPL_METHOD(DirectoryIterator, current)
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- ZVAL_OBJ(return_value, Z_OBJ_P(getThis()));
+ ZVAL_OBJ(return_value, Z_OBJ_P(ZEND_THIS));
Z_ADDREF_P(return_value);
}
/* }}} */
@@ -815,7 +815,7 @@ SPL_METHOD(DirectoryIterator, current)
Move to next entry */
SPL_METHOD(DirectoryIterator, next)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
int skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS);
if (zend_parse_parameters_none() == FAILURE) {
@@ -837,7 +837,7 @@ SPL_METHOD(DirectoryIterator, next)
Seek to the given position */
SPL_METHOD(DirectoryIterator, seek)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zval retval;
zend_long pos;
@@ -847,19 +847,19 @@ SPL_METHOD(DirectoryIterator, seek)
if (intern->u.dir.index > pos) {
/* we first rewind */
- zend_call_method_with_0_params(&EX(This), Z_OBJCE(EX(This)), &intern->u.dir.func_rewind, "rewind", NULL);
+ zend_call_method_with_0_params(ZEND_THIS, Z_OBJCE_P(ZEND_THIS), &intern->u.dir.func_rewind, "rewind", NULL);
}
while (intern->u.dir.index < pos) {
int valid = 0;
- zend_call_method_with_0_params(&EX(This), Z_OBJCE(EX(This)), &intern->u.dir.func_valid, "valid", &retval);
+ zend_call_method_with_0_params(ZEND_THIS, Z_OBJCE_P(ZEND_THIS), &intern->u.dir.func_valid, "valid", &retval);
valid = zend_is_true(&retval);
zval_ptr_dtor(&retval);
if (!valid) {
zend_throw_exception_ex(spl_ce_OutOfBoundsException, 0, "Seek position " ZEND_LONG_FMT " is out of range", pos);
return;
}
- zend_call_method_with_0_params(&EX(This), Z_OBJCE(EX(This)), &intern->u.dir.func_next, "next", NULL);
+ zend_call_method_with_0_params(ZEND_THIS, Z_OBJCE_P(ZEND_THIS), &intern->u.dir.func_next, "next", NULL);
}
} /* }}} */
@@ -867,7 +867,7 @@ SPL_METHOD(DirectoryIterator, seek)
Check whether dir contains more entries */
SPL_METHOD(DirectoryIterator, valid)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -881,7 +881,7 @@ SPL_METHOD(DirectoryIterator, valid)
Return the path */
SPL_METHOD(SplFileInfo, getPath)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
char *path;
size_t path_len;
@@ -890,7 +890,11 @@ SPL_METHOD(SplFileInfo, getPath)
}
path = spl_filesystem_object_get_path(intern, &path_len);
- RETURN_STRINGL(path, path_len);
+ if (path) {
+ RETURN_STRINGL(path, path_len);
+ } else {
+ RETURN_EMPTY_STRING();
+ }
}
/* }}} */
@@ -898,7 +902,7 @@ SPL_METHOD(SplFileInfo, getPath)
Return filename only */
SPL_METHOD(SplFileInfo, getFilename)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
size_t path_len;
if (zend_parse_parameters_none() == FAILURE) {
@@ -919,7 +923,7 @@ SPL_METHOD(SplFileInfo, getFilename)
Return filename of current dir entry */
SPL_METHOD(DirectoryIterator, getFilename)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -933,7 +937,7 @@ SPL_METHOD(DirectoryIterator, getFilename)
Returns file extension component of path */
SPL_METHOD(SplFileInfo, getExtension)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
char *fname = NULL;
const char *p;
size_t flen;
@@ -974,7 +978,7 @@ SPL_METHOD(SplFileInfo, getExtension)
Returns the file extension component of path */
SPL_METHOD(DirectoryIterator, getExtension)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
const char *p;
size_t idx;
zend_string *fname;
@@ -1001,7 +1005,7 @@ SPL_METHOD(DirectoryIterator, getExtension)
Returns filename component of path */
SPL_METHOD(SplFileInfo, getBasename)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
char *fname, *suffix = 0;
size_t flen;
size_t slen = 0, path_len;
@@ -1028,7 +1032,7 @@ SPL_METHOD(SplFileInfo, getBasename)
Returns filename component of current dir entry */
SPL_METHOD(DirectoryIterator, getBasename)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
char *suffix = 0;
size_t slen = 0;
zend_string *fname;
@@ -1047,7 +1051,7 @@ SPL_METHOD(DirectoryIterator, getBasename)
Return path and filename */
SPL_METHOD(SplFileInfo, getPathname)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
char *path;
size_t path_len;
@@ -1067,7 +1071,7 @@ SPL_METHOD(SplFileInfo, getPathname)
Return getPathname() or getFilename() depending on flags */
SPL_METHOD(FilesystemIterator, key)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1086,7 +1090,7 @@ SPL_METHOD(FilesystemIterator, key)
Return getFilename(), getFileInfo() or $this depending on flags */
SPL_METHOD(FilesystemIterator, current)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1099,7 +1103,7 @@ SPL_METHOD(FilesystemIterator, current)
spl_filesystem_object_get_file_name(intern);
spl_filesystem_object_create_type(0, intern, SPL_FS_INFO, NULL, return_value);
} else {
- ZVAL_OBJ(return_value, Z_OBJ_P(getThis()));
+ ZVAL_OBJ(return_value, Z_OBJ_P(ZEND_THIS));
Z_ADDREF_P(return_value);
/*RETURN_STRING(intern->u.dir.entry.d_name, 1);*/
}
@@ -1110,7 +1114,7 @@ SPL_METHOD(FilesystemIterator, current)
Returns true if current entry is '.' or '..' */
SPL_METHOD(DirectoryIterator, isDot)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1135,7 +1139,7 @@ SPL_METHOD(SplFileInfo, __construct)
return;
}
- intern = Z_SPLFILESYSTEM_P(getThis());
+ intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
spl_filesystem_info_set_filename(intern, path, len, 1);
@@ -1147,7 +1151,7 @@ SPL_METHOD(SplFileInfo, __construct)
#define FileInfoFunction(func_name, func_num) \
SPL_METHOD(SplFileInfo, func_name) \
{ \
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis()); \
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS); \
zend_error_handling error_handling; \
if (zend_parse_parameters_none() == FAILURE) { \
return; \
@@ -1239,7 +1243,7 @@ FileInfoFunction(isLink, FS_IS_LINK)
Return the target of a symbolic link */
SPL_METHOD(SplFileInfo, getLinkTarget)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
ssize_t ret;
char buff[MAXPATHLEN];
zend_error_handling error_handling;
@@ -1290,7 +1294,7 @@ SPL_METHOD(SplFileInfo, getLinkTarget)
Return the resolved path */
SPL_METHOD(SplFileInfo, getRealPath)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
char buff[MAXPATHLEN];
char *filename;
zend_error_handling error_handling;
@@ -1332,7 +1336,7 @@ SPL_METHOD(SplFileInfo, getRealPath)
Open the current file */
SPL_METHOD(SplFileInfo, openFile)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
spl_filesystem_object_create_type(ZEND_NUM_ARGS(), intern, SPL_FS_FILE, NULL, return_value);
}
@@ -1342,7 +1346,7 @@ SPL_METHOD(SplFileInfo, openFile)
Class to use in openFile() */
SPL_METHOD(SplFileInfo, setFileClass)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_class_entry *ce = spl_ce_SplFileObject;
zend_error_handling error_handling;
@@ -1360,7 +1364,7 @@ SPL_METHOD(SplFileInfo, setFileClass)
Class to use in getFileInfo(), getPathInfo() */
SPL_METHOD(SplFileInfo, setInfoClass)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_class_entry *ce = spl_ce_SplFileInfo;
zend_error_handling error_handling;
@@ -1378,7 +1382,7 @@ SPL_METHOD(SplFileInfo, setInfoClass)
Get/copy file info */
SPL_METHOD(SplFileInfo, getFileInfo)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_class_entry *ce = intern->info_class;
zend_error_handling error_handling;
@@ -1396,7 +1400,7 @@ SPL_METHOD(SplFileInfo, getFileInfo)
Get/copy file info */
SPL_METHOD(SplFileInfo, getPathInfo)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_class_entry *ce = intern->info_class;
zend_error_handling error_handling;
@@ -1438,7 +1442,7 @@ SPL_METHOD(FilesystemIterator, __construct)
Rewind dir back to the start */
SPL_METHOD(FilesystemIterator, rewind)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
int skip_dots = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_SKIPDOTS);
if (zend_parse_parameters_none() == FAILURE) {
@@ -1459,7 +1463,7 @@ SPL_METHOD(FilesystemIterator, rewind)
Get handling flags */
SPL_METHOD(FilesystemIterator, getFlags)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1472,7 +1476,7 @@ SPL_METHOD(FilesystemIterator, getFlags)
Set handling flags */
SPL_METHOD(FilesystemIterator, setFlags)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_long flags;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &flags) == FAILURE) {
@@ -1488,7 +1492,7 @@ SPL_METHOD(FilesystemIterator, setFlags)
SPL_METHOD(RecursiveDirectoryIterator, hasChildren)
{
zend_bool allow_links = 0;
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|b", &allow_links) == FAILURE) {
return;
@@ -1513,7 +1517,7 @@ SPL_METHOD(RecursiveDirectoryIterator, hasChildren)
SPL_METHOD(RecursiveDirectoryIterator, getChildren)
{
zval zpath, zflags;
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
spl_filesystem_object *subdir;
char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH;
@@ -1525,7 +1529,7 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren)
ZVAL_LONG(&zflags, intern->flags);
ZVAL_STRINGL(&zpath, intern->file_name, intern->file_name_len);
- spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), return_value, &zpath, &zflags);
+ spl_instantiate_arg_ex2(Z_OBJCE_P(ZEND_THIS), return_value, &zpath, &zflags);
zval_ptr_dtor(&zpath);
subdir = Z_SPLFILESYSTEM_P(return_value);
@@ -1547,7 +1551,7 @@ SPL_METHOD(RecursiveDirectoryIterator, getChildren)
Get sub path */
SPL_METHOD(RecursiveDirectoryIterator, getSubPath)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1565,7 +1569,7 @@ SPL_METHOD(RecursiveDirectoryIterator, getSubPath)
Get sub path and file name */
SPL_METHOD(RecursiveDirectoryIterator, getSubPathname)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
char slash = SPL_HAS_FLAG(intern->flags, SPL_FILE_DIR_UNIXPATHS) ? '/' : DEFAULT_SLASH;
if (zend_parse_parameters_none() == FAILURE) {
@@ -1597,11 +1601,11 @@ SPL_METHOD(GlobIterator, __construct)
}
/* }}} */
-/* {{{ proto int GlobIterator::cont()
+/* {{{ proto int GlobIterator::count()
Return the number of directories and files found by globbing */
SPL_METHOD(GlobIterator, count)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1649,7 +1653,8 @@ zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval
}
dir_object = Z_SPLFILESYSTEM_P(object);
iterator = spl_filesystem_object_to_iterator(dir_object);
- ZVAL_COPY(&iterator->intern.data, object);
+ Z_ADDREF_P(object);
+ ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(object));
iterator->intern.funcs = &spl_filesystem_dir_it_funcs;
/* ->current must be initialized; rewind doesn't set it and valid
* doesn't check whether it's set */
@@ -1850,7 +1855,8 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva
dir_object = Z_SPLFILESYSTEM_P(object);
iterator = spl_filesystem_object_to_iterator(dir_object);
- ZVAL_COPY(&iterator->intern.data, object);
+ Z_ADDREF_P(object);
+ ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(object));
iterator->intern.funcs = &spl_filesystem_tree_it_funcs;
return &iterator->intern;
@@ -2116,7 +2122,7 @@ static int spl_filesystem_file_call(spl_filesystem_object *intern, zend_function
spl_filesystem_file_call(intern, func_ptr, pass_num_args, return_value, arg2); \
} /* }}} */
-static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char delimiter, char enclosure, char escape, zval *return_value) /* {{{ */
+static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char delimiter, char enclosure, int escape, zval *return_value) /* {{{ */
{
int ret = SUCCESS;
zval *value;
@@ -2136,7 +2142,6 @@ static int spl_filesystem_file_read_csv(spl_filesystem_object *intern, char deli
php_fgetcsv(intern->u.file.stream, delimiter, enclosure, escape, buf_len, buf, &intern->u.file.current_zval);
if (return_value) {
- zval_ptr_dtor(return_value);
value = &intern->u.file.current_zval;
ZVAL_COPY_DEREF(return_value, value);
}
@@ -2161,7 +2166,7 @@ static int spl_filesystem_file_read_line_ex(zval * this_ptr, spl_filesystem_obje
return spl_filesystem_file_read_csv(intern, intern->u.file.delimiter, intern->u.file.enclosure, intern->u.file.escape, NULL);
} else {
zend_execute_data *execute_data = EG(current_execute_data);
- zend_call_method_with_0_params(this_ptr, Z_OBJCE(EX(This)), &intern->u.file.func_getCurr, "getCurrentLine", &retval);
+ zend_call_method_with_0_params(this_ptr, Z_OBJCE_P(ZEND_THIS), &intern->u.file.func_getCurr, "getCurrentLine", &retval);
}
if (!Z_ISUNDEF(retval)) {
if (intern->u.file.current_line || !Z_ISUNDEF(intern->u.file.current_zval)) {
@@ -2252,7 +2257,7 @@ static void spl_filesystem_file_rewind(zval * this_ptr, spl_filesystem_object *i
Construct a new file object */
SPL_METHOD(SplFileObject, __construct)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_bool use_include_path = 0;
char *p1, *p2;
char *tmp_path;
@@ -2314,7 +2319,7 @@ SPL_METHOD(SplTempFileObject, __construct)
{
zend_long max_memory = PHP_STREAM_MAX_MEM;
char tmp_fname[48];
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_error_handling error_handling;
if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "|l", &max_memory) == FAILURE) {
@@ -2346,20 +2351,20 @@ SPL_METHOD(SplTempFileObject, __construct)
Rewind the file and read the first line */
SPL_METHOD(SplFileObject, rewind)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- spl_filesystem_file_rewind(getThis(), intern);
+ spl_filesystem_file_rewind(ZEND_THIS, intern);
} /* }}} */
/* {{{ proto void SplFileObject::eof()
Return whether end of file is reached */
SPL_METHOD(SplFileObject, eof)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2377,7 +2382,7 @@ SPL_METHOD(SplFileObject, eof)
Return !eof() */
SPL_METHOD(SplFileObject, valid)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2397,7 +2402,7 @@ SPL_METHOD(SplFileObject, valid)
Rturn next line from file */
SPL_METHOD(SplFileObject, fgets)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2418,7 +2423,7 @@ SPL_METHOD(SplFileObject, fgets)
Return current line from file */
SPL_METHOD(SplFileObject, current)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2430,7 +2435,7 @@ SPL_METHOD(SplFileObject, current)
}
if (!intern->u.file.current_line && Z_ISUNDEF(intern->u.file.current_zval)) {
- spl_filesystem_file_read_line(getThis(), intern, 1);
+ spl_filesystem_file_read_line(ZEND_THIS, intern, 1);
}
if (intern->u.file.current_line && (!SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_CSV) || Z_ISUNDEF(intern->u.file.current_zval))) {
RETURN_STRINGL(intern->u.file.current_line, intern->u.file.current_line_len);
@@ -2447,7 +2452,7 @@ SPL_METHOD(SplFileObject, current)
Return line number */
SPL_METHOD(SplFileObject, key)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2455,7 +2460,7 @@ SPL_METHOD(SplFileObject, key)
/* Do not read the next line to support correct counting with fgetc()
if (!intern->current_line) {
- spl_filesystem_file_read_line(getThis(), intern, 1);
+ spl_filesystem_file_read_line(ZEND_THIS, intern, 1);
} */
RETURN_LONG(intern->u.file.current_line_num);
} /* }}} */
@@ -2464,7 +2469,7 @@ SPL_METHOD(SplFileObject, key)
Read next line */
SPL_METHOD(SplFileObject, next)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2472,7 +2477,7 @@ SPL_METHOD(SplFileObject, next)
spl_filesystem_file_free_line(intern);
if (SPL_HAS_FLAG(intern->flags, SPL_FILE_OBJECT_READ_AHEAD)) {
- spl_filesystem_file_read_line(getThis(), intern, 1);
+ spl_filesystem_file_read_line(ZEND_THIS, intern, 1);
}
intern->u.file.current_line_num++;
} /* }}} */
@@ -2481,7 +2486,7 @@ SPL_METHOD(SplFileObject, next)
Set file handling flags */
SPL_METHOD(SplFileObject, setFlags)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &intern->flags) == FAILURE) {
return;
@@ -2492,7 +2497,7 @@ SPL_METHOD(SplFileObject, setFlags)
Get file handling flags */
SPL_METHOD(SplFileObject, getFlags)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2507,7 +2512,7 @@ SPL_METHOD(SplFileObject, setMaxLineLen)
{
zend_long max_len;
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &max_len) == FAILURE) {
return;
@@ -2525,7 +2530,7 @@ SPL_METHOD(SplFileObject, setMaxLineLen)
Get maximum line length */
SPL_METHOD(SplFileObject, getMaxLineLen)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2559,7 +2564,7 @@ SPL_METHOD(SplFileObject, getChildren)
#define FileFunction(func_name) \
SPL_METHOD(SplFileObject, func_name) \
{ \
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis()); \
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS); \
FileFunctionCall(func_name, ZEND_NUM_ARGS(), NULL); \
}
/* }}} */
@@ -2568,8 +2573,9 @@ SPL_METHOD(SplFileObject, func_name) \
Return current line as csv */
SPL_METHOD(SplFileObject, fgetcsv)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
- char delimiter = intern->u.file.delimiter, enclosure = intern->u.file.enclosure, escape = intern->u.file.escape;
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
+ char delimiter = intern->u.file.delimiter, enclosure = intern->u.file.enclosure;
+ int escape = intern->u.file.escape;
char *delim = NULL, *enclo = NULL, *esc = NULL;
size_t d_len = 0, e_len = 0, esc_len = 0;
@@ -2583,11 +2589,15 @@ SPL_METHOD(SplFileObject, fgetcsv)
switch(ZEND_NUM_ARGS())
{
case 3:
- if (esc_len != 1) {
- php_error_docref(NULL, E_WARNING, "escape must be a character");
+ if (esc_len > 1) {
+ php_error_docref(NULL, E_WARNING, "escape must be empty or a single character");
RETURN_FALSE;
}
- escape = esc[0];
+ if (esc_len == 0) {
+ escape = PHP_CSV_NO_ESCAPE;
+ } else {
+ escape = (unsigned char) esc[0];
+ }
/* no break */
case 2:
if (e_len != 1) {
@@ -2615,8 +2625,9 @@ SPL_METHOD(SplFileObject, fgetcsv)
Output a field array as a CSV line */
SPL_METHOD(SplFileObject, fputcsv)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
- char delimiter = intern->u.file.delimiter, enclosure = intern->u.file.enclosure, escape = intern->u.file.escape;
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
+ char delimiter = intern->u.file.delimiter, enclosure = intern->u.file.enclosure;
+ int escape = intern->u.file.escape;
char *delim = NULL, *enclo = NULL, *esc = NULL;
size_t d_len = 0, e_len = 0, esc_len = 0;
zend_long ret;
@@ -2626,11 +2637,17 @@ SPL_METHOD(SplFileObject, fputcsv)
switch(ZEND_NUM_ARGS())
{
case 4:
- if (esc_len != 1) {
- php_error_docref(NULL, E_WARNING, "escape must be a character");
- RETURN_FALSE;
+ switch (esc_len) {
+ case 0:
+ escape = PHP_CSV_NO_ESCAPE;
+ break;
+ case 1:
+ escape = (unsigned char) esc[0];
+ break;
+ default:
+ php_error_docref(NULL, E_WARNING, "escape must be empty or a single character");
+ RETURN_FALSE;
}
- escape = esc[0];
/* no break */
case 3:
if (e_len != 1) {
@@ -2660,8 +2677,9 @@ SPL_METHOD(SplFileObject, fputcsv)
Set the delimiter, enclosure and escape character used in fgetcsv */
SPL_METHOD(SplFileObject, setCsvControl)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
- char delimiter = ',', enclosure = '"', escape='\\';
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
+ char delimiter = ',', enclosure = '"';
+ int escape = (unsigned char) '\\';
char *delim = NULL, *enclo = NULL, *esc = NULL;
size_t d_len = 0, e_len = 0, esc_len = 0;
@@ -2669,11 +2687,17 @@ SPL_METHOD(SplFileObject, setCsvControl)
switch(ZEND_NUM_ARGS())
{
case 3:
- if (esc_len != 1) {
- php_error_docref(NULL, E_WARNING, "escape must be a character");
- RETURN_FALSE;
+ switch (esc_len) {
+ case 0:
+ escape = PHP_CSV_NO_ESCAPE;
+ break;
+ case 1:
+ escape = (unsigned char) esc[0];
+ break;
+ default:
+ php_error_docref(NULL, E_WARNING, "escape must be empty or a single character");
+ RETURN_FALSE;
}
- escape = esc[0];
/* no break */
case 2:
if (e_len != 1) {
@@ -2703,7 +2727,7 @@ SPL_METHOD(SplFileObject, setCsvControl)
Get the delimiter, enclosure and escape character used in fgetcsv */
SPL_METHOD(SplFileObject, getCsvControl)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
char delimiter[2], enclosure[2], escape[2];
array_init(return_value);
@@ -2712,8 +2736,12 @@ SPL_METHOD(SplFileObject, getCsvControl)
delimiter[1] = '\0';
enclosure[0] = intern->u.file.enclosure;
enclosure[1] = '\0';
- escape[0] = intern->u.file.escape;
- escape[1] = '\0';
+ if (intern->u.file.escape == PHP_CSV_NO_ESCAPE) {
+ escape[0] = '\0';
+ } else {
+ escape[0] = (unsigned char) intern->u.file.escape;
+ escape[1] = '\0';
+ }
add_next_index_string(return_value, delimiter);
add_next_index_string(return_value, enclosure);
@@ -2730,7 +2758,7 @@ FileFunction(flock)
Flush the file */
SPL_METHOD(SplFileObject, fflush)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if(!intern->u.file.stream) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized");
@@ -2744,7 +2772,7 @@ SPL_METHOD(SplFileObject, fflush)
Return current file position */
SPL_METHOD(SplFileObject, ftell)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_long ret;
if(!intern->u.file.stream) {
@@ -2765,7 +2793,7 @@ SPL_METHOD(SplFileObject, ftell)
Return current file position */
SPL_METHOD(SplFileObject, fseek)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_long pos, whence = SEEK_SET;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l|l", &pos, &whence) == FAILURE) {
@@ -2785,7 +2813,7 @@ SPL_METHOD(SplFileObject, fseek)
Get a character form the file */
SPL_METHOD(SplFileObject, fgetc)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
char buf[2];
int result;
@@ -2815,7 +2843,7 @@ SPL_METHOD(SplFileObject, fgetc)
Get a line from file pointer and strip HTML tags */
SPL_METHOD(SplFileObject, fgetss)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zval arg2;
if(!intern->u.file.stream) {
@@ -2839,7 +2867,7 @@ SPL_METHOD(SplFileObject, fgetss)
Output all remaining data from a file pointer */
SPL_METHOD(SplFileObject, fpassthru)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if(!intern->u.file.stream) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized");
@@ -2853,7 +2881,7 @@ SPL_METHOD(SplFileObject, fpassthru)
Implements a mostly ANSI compatible fscanf() */
SPL_METHOD(SplFileObject, fscanf)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
if(!intern->u.file.stream) {
zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized");
@@ -2867,14 +2895,15 @@ SPL_METHOD(SplFileObject, fscanf)
}
/* }}} */
-/* {{{ proto mixed SplFileObject::fwrite(string str [, int length])
+/* {{{ proto int|false SplFileObject::fwrite(string str [, int length])
Binary-safe file write */
SPL_METHOD(SplFileObject, fwrite)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
char *str;
size_t str_len;
zend_long length = 0;
+ ssize_t written;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "s|l", &str, &str_len, &length) == FAILURE) {
return;
@@ -2897,13 +2926,18 @@ SPL_METHOD(SplFileObject, fwrite)
RETURN_LONG(0);
}
- RETURN_LONG(php_stream_write(intern->u.file.stream, str, str_len));
+ written = php_stream_write(intern->u.file.stream, str, str_len);
+ if (written < 0) {
+ RETURN_FALSE;
+ }
+ RETURN_LONG(written);
} /* }}} */
SPL_METHOD(SplFileObject, fread)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_long length = 0;
+ zend_string *str;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &length) == FAILURE) {
return;
@@ -2919,11 +2953,11 @@ SPL_METHOD(SplFileObject, fread)
RETURN_FALSE;
}
- ZVAL_NEW_STR(return_value, zend_string_alloc(length, 0));
- Z_STRLEN_P(return_value) = php_stream_read(intern->u.file.stream, Z_STRVAL_P(return_value), length);
-
- /* needed because recv/read/gzread doesn't put a null at the end*/
- Z_STRVAL_P(return_value)[Z_STRLEN_P(return_value)] = 0;
+ str = php_stream_read_to_str(intern->u.file.stream, length);
+ if (!str) {
+ RETURN_FALSE;
+ }
+ RETURN_STR(str);
}
/* {{{ proto bool SplFileObject::fstat()
@@ -2935,7 +2969,7 @@ FileFunction(fstat)
Truncate file to 'size' length */
SPL_METHOD(SplFileObject, ftruncate)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_long size;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &size) == FAILURE) {
@@ -2959,7 +2993,7 @@ SPL_METHOD(SplFileObject, ftruncate)
Seek to specified line */
SPL_METHOD(SplFileObject, seek)
{
- spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(getThis());
+ spl_filesystem_object *intern = Z_SPLFILESYSTEM_P(ZEND_THIS);
zend_long line_pos;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &line_pos) == FAILURE) {
@@ -2975,10 +3009,10 @@ SPL_METHOD(SplFileObject, seek)
RETURN_FALSE;
}
- spl_filesystem_file_rewind(getThis(), intern);
+ spl_filesystem_file_rewind(ZEND_THIS, intern);
while(intern->u.file.current_line_num < line_pos) {
- if (spl_filesystem_file_read_line(getThis(), intern, 1) == FAILURE) {
+ if (spl_filesystem_file_read_line(ZEND_THIS, intern, 1) == FAILURE) {
break;
}
}
@@ -3161,12 +3195,3 @@ PHP_MINIT_FUNCTION(spl_directory)
return SUCCESS;
}
/* }}} */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/spl/spl_directory.h b/ext/spl/spl_directory.h
index 2bbdadfe6d..90e8945a16 100644
--- a/ext/spl/spl_directory.h
+++ b/ext/spl/spl_directory.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -96,7 +96,7 @@ struct _spl_filesystem_object {
zend_function *func_getCurr;
char delimiter;
char enclosure;
- char escape;
+ int escape;
} file;
} u;
zend_object std;
@@ -147,12 +147,3 @@ static inline spl_filesystem_object* spl_filesystem_iterator_to_object(spl_files
#define SPL_FILE_DIR_OTHERS_MASK 0x00003000 /* mask used for get/setFlags */
#endif /* SPL_DIRECTORY_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/spl_dllist.c b/ext/spl/spl_dllist.c
index 10e104270c..10aaa1ca01 100644
--- a/ext/spl/spl_dllist.c
+++ b/ext/spl/spl_dllist.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -567,7 +567,7 @@ SPL_METHOD(SplDoublyLinkedList, push)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
spl_ptr_llist_push(intern->llist, value);
RETURN_TRUE;
@@ -585,7 +585,7 @@ SPL_METHOD(SplDoublyLinkedList, unshift)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
spl_ptr_llist_unshift(intern->llist, value);
RETURN_TRUE;
@@ -602,7 +602,7 @@ SPL_METHOD(SplDoublyLinkedList, pop)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
spl_ptr_llist_pop(intern->llist, return_value);
if (Z_ISUNDEF_P(return_value)) {
@@ -622,7 +622,7 @@ SPL_METHOD(SplDoublyLinkedList, shift)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
spl_ptr_llist_shift(intern->llist, return_value);
if (Z_ISUNDEF_P(return_value)) {
@@ -643,7 +643,7 @@ SPL_METHOD(SplDoublyLinkedList, top)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
value = spl_ptr_llist_last(intern->llist);
if (value == NULL || Z_ISUNDEF_P(value)) {
@@ -666,7 +666,7 @@ SPL_METHOD(SplDoublyLinkedList, bottom)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
value = spl_ptr_llist_first(intern->llist);
if (value == NULL || Z_ISUNDEF_P(value)) {
@@ -683,7 +683,7 @@ SPL_METHOD(SplDoublyLinkedList, bottom)
SPL_METHOD(SplDoublyLinkedList, count)
{
zend_long count;
- spl_dllist_object *intern = Z_SPLDLLIST_P(getThis());
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -704,12 +704,12 @@ SPL_METHOD(SplDoublyLinkedList, isEmpty)
return;
}
- spl_dllist_object_count_elements(getThis(), &count);
+ spl_dllist_object_count_elements(ZEND_THIS, &count);
RETURN_BOOL(count == 0);
}
/* }}} */
-/* {{{ proto int SplDoublyLinkedList::setIteratorMode(int flags)
+/* {{{ proto int SplDoublyLinkedList::setIteratorMode(int mode)
Set the mode of iteration */
SPL_METHOD(SplDoublyLinkedList, setIteratorMode)
{
@@ -720,7 +720,7 @@ SPL_METHOD(SplDoublyLinkedList, setIteratorMode)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
if (intern->flags & SPL_DLLIST_IT_FIX
&& (intern->flags & SPL_DLLIST_IT_LIFO) != (value & SPL_DLLIST_IT_LIFO)) {
@@ -744,7 +744,7 @@ SPL_METHOD(SplDoublyLinkedList, getIteratorMode)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
RETURN_LONG(intern->flags);
}
@@ -762,7 +762,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetExists)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
index = spl_offset_convert_to_long(zindex);
RETURN_BOOL(index >= 0 && index < intern->llist->count);
@@ -781,7 +781,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetGet)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
index = spl_offset_convert_to_long(zindex);
if (index < 0 || index >= intern->llist->count) {
@@ -811,7 +811,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetSet)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
if (Z_TYPE_P(zindex) == IS_NULL) {
/* $obj[] = ... */
@@ -867,7 +867,7 @@ SPL_METHOD(SplDoublyLinkedList, offsetUnset)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
index = spl_offset_convert_to_long(zindex);
llist = intern->llist;
@@ -1034,7 +1034,7 @@ static void spl_dllist_it_move_forward(zend_object_iterator *iter) /* {{{ */
Return current array key */
SPL_METHOD(SplDoublyLinkedList, key)
{
- spl_dllist_object *intern = Z_SPLDLLIST_P(getThis());
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1048,7 +1048,7 @@ SPL_METHOD(SplDoublyLinkedList, key)
Move to next entry */
SPL_METHOD(SplDoublyLinkedList, prev)
{
- spl_dllist_object *intern = Z_SPLDLLIST_P(getThis());
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1062,7 +1062,7 @@ SPL_METHOD(SplDoublyLinkedList, prev)
Move to next entry */
SPL_METHOD(SplDoublyLinkedList, next)
{
- spl_dllist_object *intern = Z_SPLDLLIST_P(getThis());
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1076,7 +1076,7 @@ SPL_METHOD(SplDoublyLinkedList, next)
Check whether the datastructure contains more entries */
SPL_METHOD(SplDoublyLinkedList, valid)
{
- spl_dllist_object *intern = Z_SPLDLLIST_P(getThis());
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1090,7 +1090,7 @@ SPL_METHOD(SplDoublyLinkedList, valid)
Rewind the datastructure back to the start */
SPL_METHOD(SplDoublyLinkedList, rewind)
{
- spl_dllist_object *intern = Z_SPLDLLIST_P(getThis());
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1104,7 +1104,7 @@ SPL_METHOD(SplDoublyLinkedList, rewind)
Return current datastructure entry */
SPL_METHOD(SplDoublyLinkedList, current)
{
- spl_dllist_object *intern = Z_SPLDLLIST_P(getThis());
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
spl_ptr_llist_element *element = intern->traverse_pointer;
if (zend_parse_parameters_none() == FAILURE) {
@@ -1125,7 +1125,7 @@ SPL_METHOD(SplDoublyLinkedList, current)
Serializes storage */
SPL_METHOD(SplDoublyLinkedList, serialize)
{
- spl_dllist_object *intern = Z_SPLDLLIST_P(getThis());
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
smart_str buf = {0};
spl_ptr_llist_element *current = intern->llist->head, *next;
zval flags;
@@ -1168,7 +1168,7 @@ SPL_METHOD(SplDoublyLinkedList, serialize)
Unserializes storage */
SPL_METHOD(SplDoublyLinkedList, unserialize)
{
- spl_dllist_object *intern = Z_SPLDLLIST_P(getThis());
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
zval *flags, *elem;
char *buf;
size_t buf_len;
@@ -1220,6 +1220,68 @@ error:
} /* }}} */
+/* {{{ proto array SplDoublyLinkedList::__serialize() */
+SPL_METHOD(SplDoublyLinkedList, __serialize)
+{
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
+ spl_ptr_llist_element *current = intern->llist->head;
+ zval tmp;
+
+ if (zend_parse_parameters_none_throw() == FAILURE) {
+ return;
+ }
+
+ array_init(return_value);
+
+ /* flags */
+ ZVAL_LONG(&tmp, intern->flags);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
+
+ /* elements */
+ array_init_size(&tmp, intern->llist->count);
+ while (current) {
+ zend_hash_next_index_insert(Z_ARRVAL(tmp), &current->data);
+ Z_TRY_ADDREF(current->data);
+ current = current->next;
+ }
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
+
+ /* members */
+ ZVAL_ARR(&tmp, zend_std_get_properties(ZEND_THIS));
+ Z_TRY_ADDREF(tmp);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
+} /* }}} */
+
+/* {{{ proto void SplDoublyLinkedList::__unserialize(array serialized) */
+SPL_METHOD(SplDoublyLinkedList, __unserialize) {
+ spl_dllist_object *intern = Z_SPLDLLIST_P(ZEND_THIS);
+ HashTable *data;
+ zval *flags_zv, *storage_zv, *members_zv, *elem;
+
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "h", &data) == FAILURE) {
+ return;
+ }
+
+ flags_zv = zend_hash_index_find(data, 0);
+ storage_zv = zend_hash_index_find(data, 1);
+ members_zv = zend_hash_index_find(data, 2);
+ if (!flags_zv || !storage_zv || !members_zv ||
+ Z_TYPE_P(flags_zv) != IS_LONG || Z_TYPE_P(storage_zv) != IS_ARRAY ||
+ Z_TYPE_P(members_zv) != IS_ARRAY) {
+ zend_throw_exception(spl_ce_UnexpectedValueException,
+ "Incomplete or ill-typed serialization data", 0);
+ return;
+ }
+
+ intern->flags = (int) Z_LVAL_P(flags_zv);
+
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(storage_zv), elem) {
+ spl_ptr_llist_push(intern->llist, elem);
+ } ZEND_HASH_FOREACH_END();
+
+ object_properties_load(&intern->std, Z_ARRVAL_P(members_zv));
+} /* }}} */
+
/* {{{ proto void SplDoublyLinkedList::add(mixed index, mixed newval)
Inserts a new entry before the specified $index consisting of $newval. */
SPL_METHOD(SplDoublyLinkedList, add)
@@ -1233,7 +1295,7 @@ SPL_METHOD(SplDoublyLinkedList, add)
return;
}
- intern = Z_SPLDLLIST_P(getThis());
+ intern = Z_SPLDLLIST_P(ZEND_THIS);
index = spl_offset_convert_to_long(zindex);
if (index < 0 || index > intern->llist->count) {
@@ -1299,7 +1361,8 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object
zend_iterator_init((zend_object_iterator*)iterator);
- ZVAL_COPY(&iterator->intern.it.data, object);
+ Z_ADDREF_P(object);
+ ZVAL_OBJ(&iterator->intern.it.data, Z_OBJ_P(object));
iterator->intern.it.funcs = &spl_dllist_it_funcs;
iterator->intern.ce = ce;
iterator->traverse_position = dllist_object->traverse_position;
@@ -1315,7 +1378,7 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object
/* Function/Class/Method definitions */
ZEND_BEGIN_ARG_INFO(arginfo_dllist_setiteratormode, 0)
- ZEND_ARG_INFO(0, flags)
+ ZEND_ARG_INFO(0, mode)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_dllist_push, 0)
@@ -1374,6 +1437,8 @@ static const zend_function_entry spl_funcs_SplDoublyLinkedList[] = {
/* Serializable */
SPL_ME(SplDoublyLinkedList, unserialize, arginfo_dllist_serialized, ZEND_ACC_PUBLIC)
SPL_ME(SplDoublyLinkedList, serialize, arginfo_dllist_void, ZEND_ACC_PUBLIC)
+ SPL_ME(SplDoublyLinkedList, __unserialize, arginfo_dllist_serialized, ZEND_ACC_PUBLIC)
+ SPL_ME(SplDoublyLinkedList, __serialize, arginfo_dllist_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
/* }}} */
@@ -1412,12 +1477,3 @@ PHP_MINIT_FUNCTION(spl_dllist) /* {{{ */
return SUCCESS;
}
/* }}} */
-
-/*
- * 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_dllist.h b/ext/spl/spl_dllist.h
index fad7f6285a..3f53864d25 100644
--- a/ext/spl/spl_dllist.h
+++ b/ext/spl/spl_dllist.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -29,12 +29,3 @@ extern PHPAPI zend_class_entry *spl_ce_SplStack;
PHP_MINIT_FUNCTION(spl_dllist);
#endif /* SPL_DLLIST_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/spl_engine.c b/ext/spl/spl_engine.c
index caf0f9912c..7bedefe2c4 100644
--- a/ext/spl/spl_engine.c
+++ b/ext/spl/spl_engine.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -66,12 +66,3 @@ try_again:
return -1;
}
/* }}} */
-
-/*
- * 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_engine.h b/ext/spl/spl_engine.h
index de46e59411..c5614a691d 100644
--- a/ext/spl/spl_engine.h
+++ b/ext/spl/spl_engine.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -76,12 +76,3 @@ static inline void spl_instantiate_arg_n(zend_class_entry *pce, zval *retval, in
/* }}} */
#endif /* SPL_ENGINE_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/spl_exceptions.c b/ext/spl/spl_exceptions.c
index f2a16beaee..abe70c2b34 100644
--- a/ext/spl/spl_exceptions.c
+++ b/ext/spl/spl_exceptions.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -68,12 +68,3 @@ PHP_MINIT_FUNCTION(spl_exceptions)
return SUCCESS;
}
/* }}} */
-
-/*
- * 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_exceptions.h b/ext/spl/spl_exceptions.h
index d500a91efc..2c36287bbb 100644
--- a/ext/spl/spl_exceptions.h
+++ b/ext/spl/spl_exceptions.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -40,12 +40,3 @@ extern PHPAPI zend_class_entry *spl_ce_UnexpectedValueException;
PHP_MINIT_FUNCTION(spl_exceptions);
#endif /* SPL_EXCEPTIONS_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/spl_fixedarray.c b/ext/spl/spl_fixedarray.c
index 392175f781..d80509f851 100644
--- a/ext/spl/spl_fixedarray.c
+++ b/ext/spl/spl_fixedarray.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -207,6 +207,7 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z
spl_fixedarray_object *intern;
zend_class_entry *parent = class_type;
int inherited = 0;
+ zend_class_iterator_funcs *funcs_ptr;
intern = zend_object_alloc(sizeof(spl_fixedarray_object), parent);
@@ -226,7 +227,6 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z
while (parent) {
if (parent == spl_ce_SplFixedArray) {
intern->std.handlers = &spl_handler_SplFixedArray;
- class_type->get_iterator = spl_fixedarray_get_iterator;
break;
}
@@ -238,27 +238,28 @@ static zend_object *spl_fixedarray_object_new_ex(zend_class_entry *class_type, z
php_error_docref(NULL, E_COMPILE_ERROR, "Internal compiler error, Class is not child of SplFixedArray");
}
- if (!class_type->iterator_funcs_ptr->zf_current) {
- class_type->iterator_funcs_ptr->zf_rewind = zend_hash_str_find_ptr(&class_type->function_table, "rewind", sizeof("rewind") - 1);
- class_type->iterator_funcs_ptr->zf_valid = zend_hash_str_find_ptr(&class_type->function_table, "valid", sizeof("valid") - 1);
- class_type->iterator_funcs_ptr->zf_key = zend_hash_str_find_ptr(&class_type->function_table, "key", sizeof("key") - 1);
- class_type->iterator_funcs_ptr->zf_current = zend_hash_str_find_ptr(&class_type->function_table, "current", sizeof("current") - 1);
- class_type->iterator_funcs_ptr->zf_next = zend_hash_str_find_ptr(&class_type->function_table, "next", sizeof("next") - 1);
+ funcs_ptr = class_type->iterator_funcs_ptr;
+ if (!funcs_ptr->zf_current) {
+ funcs_ptr->zf_rewind = zend_hash_str_find_ptr(&class_type->function_table, "rewind", sizeof("rewind") - 1);
+ funcs_ptr->zf_valid = zend_hash_str_find_ptr(&class_type->function_table, "valid", sizeof("valid") - 1);
+ funcs_ptr->zf_key = zend_hash_str_find_ptr(&class_type->function_table, "key", sizeof("key") - 1);
+ funcs_ptr->zf_current = zend_hash_str_find_ptr(&class_type->function_table, "current", sizeof("current") - 1);
+ funcs_ptr->zf_next = zend_hash_str_find_ptr(&class_type->function_table, "next", sizeof("next") - 1);
}
if (inherited) {
- if (class_type->iterator_funcs_ptr->zf_rewind->common.scope != parent) {
+ if (funcs_ptr->zf_rewind->common.scope != parent) {
intern->flags |= SPL_FIXEDARRAY_OVERLOADED_REWIND;
}
- if (class_type->iterator_funcs_ptr->zf_valid->common.scope != parent) {
+ if (funcs_ptr->zf_valid->common.scope != parent) {
intern->flags |= SPL_FIXEDARRAY_OVERLOADED_VALID;
}
- if (class_type->iterator_funcs_ptr->zf_key->common.scope != parent) {
+ if (funcs_ptr->zf_key->common.scope != parent) {
intern->flags |= SPL_FIXEDARRAY_OVERLOADED_KEY;
}
- if (class_type->iterator_funcs_ptr->zf_current->common.scope != parent) {
+ if (funcs_ptr->zf_current->common.scope != parent) {
intern->flags |= SPL_FIXEDARRAY_OVERLOADED_CURRENT;
}
- if (class_type->iterator_funcs_ptr->zf_next->common.scope != parent) {
+ if (funcs_ptr->zf_next->common.scope != parent) {
intern->flags |= SPL_FIXEDARRAY_OVERLOADED_NEXT;
}
@@ -546,7 +547,7 @@ static int spl_fixedarray_object_count_elements(zval *object, zend_long *count)
*/
SPL_METHOD(SplFixedArray, __construct)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_fixedarray_object *intern;
zend_long size = 0;
@@ -574,8 +575,8 @@ SPL_METHOD(SplFixedArray, __construct)
*/
SPL_METHOD(SplFixedArray, __wakeup)
{
- spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
- HashTable *intern_ht = zend_std_get_properties(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
+ HashTable *intern_ht = zend_std_get_properties(ZEND_THIS);
zval *data;
if (zend_parse_parameters_none() == FAILURE) {
@@ -604,7 +605,7 @@ SPL_METHOD(SplFixedArray, __wakeup)
*/
SPL_METHOD(SplFixedArray, count)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_fixedarray_object *intern;
if (zend_parse_parameters_none() == FAILURE) {
@@ -626,7 +627,7 @@ SPL_METHOD(SplFixedArray, toArray)
return;
}
- intern = Z_SPLFIXEDARRAY_P(getThis());
+ intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
if (intern->array.size > 0) {
int i = 0;
@@ -641,12 +642,12 @@ SPL_METHOD(SplFixedArray, toArray)
}
}
} else {
- ZVAL_EMPTY_ARRAY(return_value);
+ RETURN_EMPTY_ARRAY();
}
}
/* }}} */
-/* {{{ proto object SplFixedArray::fromArray(array data[, bool save_indexes])
+/* {{{ proto object SplFixedArray::fromArray(array array[, bool save_indexes])
*/
SPL_METHOD(SplFixedArray, fromArray)
{
@@ -715,7 +716,7 @@ SPL_METHOD(SplFixedArray, fromArray)
*/
SPL_METHOD(SplFixedArray, getSize)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_fixedarray_object *intern;
if (zend_parse_parameters_none() == FAILURE) {
@@ -731,7 +732,7 @@ SPL_METHOD(SplFixedArray, getSize)
*/
SPL_METHOD(SplFixedArray, setSize)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_fixedarray_object *intern;
zend_long size;
@@ -762,7 +763,7 @@ SPL_METHOD(SplFixedArray, offsetExists)
return;
}
- intern = Z_SPLFIXEDARRAY_P(getThis());
+ intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
RETURN_BOOL(spl_fixedarray_object_has_dimension_helper(intern, zindex, 0));
} /* }}} */
@@ -778,7 +779,7 @@ SPL_METHOD(SplFixedArray, offsetGet)
return;
}
- intern = Z_SPLFIXEDARRAY_P(getThis());
+ intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
value = spl_fixedarray_object_read_dimension_helper(intern, zindex);
if (value) {
@@ -799,7 +800,7 @@ SPL_METHOD(SplFixedArray, offsetSet)
return;
}
- intern = Z_SPLFIXEDARRAY_P(getThis());
+ intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
spl_fixedarray_object_write_dimension_helper(intern, zindex, value);
} /* }}} */
@@ -815,7 +816,7 @@ SPL_METHOD(SplFixedArray, offsetUnset)
return;
}
- intern = Z_SPLFIXEDARRAY_P(getThis());
+ intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
spl_fixedarray_object_unset_dimension_helper(intern, zindex);
} /* }}} */
@@ -908,7 +909,7 @@ static void spl_fixedarray_it_move_forward(zend_object_iterator *iter) /* {{{ */
Return current array key */
SPL_METHOD(SplFixedArray, key)
{
- spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -922,7 +923,7 @@ SPL_METHOD(SplFixedArray, key)
Move to next entry */
SPL_METHOD(SplFixedArray, next)
{
- spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -936,7 +937,7 @@ SPL_METHOD(SplFixedArray, next)
Check whether the datastructure contains more entries */
SPL_METHOD(SplFixedArray, valid)
{
- spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -950,7 +951,7 @@ SPL_METHOD(SplFixedArray, valid)
Rewind the datastructure back to the start */
SPL_METHOD(SplFixedArray, rewind)
{
- spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -965,7 +966,7 @@ SPL_METHOD(SplFixedArray, rewind)
SPL_METHOD(SplFixedArray, current)
{
zval zindex, *value;
- spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(getThis());
+ spl_fixedarray_object *intern = Z_SPLFIXEDARRAY_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1007,7 +1008,8 @@ zend_object_iterator *spl_fixedarray_get_iterator(zend_class_entry *ce, zval *ob
zend_iterator_init((zend_object_iterator*)iterator);
- ZVAL_COPY(&iterator->intern.it.data, object);
+ Z_ADDREF_P(object);
+ ZVAL_OBJ(&iterator->intern.it.data, Z_OBJ_P(object));
iterator->intern.it.funcs = &spl_fixedarray_it_funcs;
iterator->intern.ce = ce;
ZVAL_UNDEF(&iterator->intern.value);
@@ -1034,7 +1036,7 @@ ZEND_BEGIN_ARG_INFO(arginfo_fixedarray_setSize, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_fixedarray_fromArray, 0, 0, 1)
- ZEND_ARG_INFO(0, data)
+ ZEND_ARG_INFO(0, array)
ZEND_ARG_INFO(0, save_indexes)
ZEND_END_ARG_INFO()
@@ -1085,17 +1087,8 @@ PHP_MINIT_FUNCTION(spl_fixedarray)
REGISTER_SPL_IMPLEMENTS(SplFixedArray, Countable);
spl_ce_SplFixedArray->get_iterator = spl_fixedarray_get_iterator;
+ spl_ce_SplFixedArray->ce_flags |= ZEND_ACC_REUSE_GET_ITERATOR;
return SUCCESS;
}
/* }}} */
-
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/spl/spl_fixedarray.h b/ext/spl/spl_fixedarray.h
index eb2e3d97bf..9be62d4b89 100644
--- a/ext/spl/spl_fixedarray.h
+++ b/ext/spl/spl_fixedarray.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -25,12 +25,3 @@ extern PHPAPI zend_class_entry *spl_ce_SplFixedArray;
PHP_MINIT_FUNCTION(spl_fixedarray);
#endif /* SPL_FIXEDARRAY_H */
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * End:
- * vim600: noet sw=4 ts=4 fdm=marker
- * vim<600: noet sw=4 ts=4
- */
diff --git a/ext/spl/spl_functions.c b/ext/spl/spl_functions.c
index 75e264f34b..74d7e75667 100644
--- a/ext/spl/spl_functions.c
+++ b/ext/spl/spl_functions.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -94,8 +94,11 @@ void spl_add_interfaces(zval *list, zend_class_entry * pce, int allow, int ce_fl
{
uint32_t num_interfaces;
- for (num_interfaces = 0; num_interfaces < pce->num_interfaces; num_interfaces++) {
- spl_add_class_name(list, pce->interfaces[num_interfaces], allow, ce_flags);
+ if (pce->num_interfaces) {
+ ZEND_ASSERT(pce->ce_flags & ZEND_ACC_LINKED);
+ for (num_interfaces = 0; num_interfaces < pce->num_interfaces; num_interfaces++) {
+ spl_add_class_name(list, pce->interfaces[num_interfaces], allow, ce_flags);
+ }
}
}
/* }}} */
@@ -104,9 +107,13 @@ void spl_add_interfaces(zval *list, zend_class_entry * pce, int allow, int ce_fl
void spl_add_traits(zval *list, zend_class_entry * pce, int allow, int ce_flags)
{
uint32_t num_traits;
+ zend_class_entry *trait;
for (num_traits = 0; num_traits < pce->num_traits; num_traits++) {
- spl_add_class_name(list, pce->traits[num_traits], allow, ce_flags);
+ trait = zend_fetch_class_by_name(pce->trait_names[num_traits].name,
+ pce->trait_names[num_traits].lc_name, ZEND_FETCH_CLASS_TRAIT);
+ ZEND_ASSERT(trait);
+ spl_add_class_name(list, trait, allow, ce_flags);
}
}
/* }}} */
@@ -135,12 +142,3 @@ zend_string * spl_gen_private_prop_name(zend_class_entry *ce, char *prop_name, i
return zend_mangle_property_name(ZSTR_VAL(ce->name), ZSTR_LEN(ce->name), prop_name, prop_len, 0);
}
/* }}} */
-
-/*
- * 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_functions.h b/ext/spl/spl_functions.h
index c8f43d5dd6..2b9ff7890d 100644
--- a/ext/spl/spl_functions.h
+++ b/ext/spl/spl_functions.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -78,12 +78,3 @@ zend_string *spl_gen_private_prop_name(zend_class_entry *ce, char *prop_name, in
#define SPL_MA(class_name, function_name, alias_class, alias_function, arg_info, flags) \
PHP_MALIAS(spl_ ## alias_class, function_name, alias_function, arg_info, flags)
#endif /* PHP_FUNCTIONS_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/spl_heap.c b/ext/spl/spl_heap.c
index 4c170dd8d4..8191c2901d 100644
--- a/ext/spl/spl_heap.c
+++ b/ext/spl/spl_heap.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -48,18 +48,19 @@ PHPAPI zend_class_entry *spl_ce_SplMinHeap;
PHPAPI zend_class_entry *spl_ce_SplPriorityQueue;
-typedef void (*spl_ptr_heap_dtor_func)(zval *);
-typedef void (*spl_ptr_heap_ctor_func)(zval *);
-typedef int (*spl_ptr_heap_cmp_func)(zval *, zval *, zval *);
+typedef void (*spl_ptr_heap_dtor_func)(void *);
+typedef void (*spl_ptr_heap_ctor_func)(void *);
+typedef int (*spl_ptr_heap_cmp_func)(void *, void *, zval *);
typedef struct _spl_ptr_heap {
- zval *elements;
+ void *elements;
spl_ptr_heap_ctor_func ctor;
spl_ptr_heap_dtor_func dtor;
spl_ptr_heap_cmp_func cmp;
int count;
- int max_size;
int flags;
+ size_t max_size;
+ size_t elem_size;
} spl_ptr_heap;
typedef struct _spl_heap_object spl_heap_object;
@@ -80,6 +81,11 @@ struct _spl_heap_it {
int flags;
};
+typedef struct _spl_pqueue_elem {
+ zval data;
+ zval priority;
+} spl_pqueue_elem;
+
static inline spl_heap_object *spl_heap_from_obj(zend_object *obj) /* {{{ */ {
return (spl_heap_object*)((char*)(obj) - XtOffsetOf(spl_heap_object, std));
}
@@ -87,15 +93,35 @@ static inline spl_heap_object *spl_heap_from_obj(zend_object *obj) /* {{{ */ {
#define Z_SPLHEAP_P(zv) spl_heap_from_obj(Z_OBJ_P((zv)))
-static void spl_ptr_heap_zval_dtor(zval *elem) { /* {{{ */
- if (!Z_ISUNDEF_P(elem)) {
- zval_ptr_dtor(elem);
- }
+static zend_always_inline void *spl_heap_elem(spl_ptr_heap *heap, size_t i) {
+ return (void *) ((char *) heap->elements + heap->elem_size * i);
+}
+
+static zend_always_inline void spl_heap_elem_copy(spl_ptr_heap *heap, void *to, void *from) {
+ memcpy(to, from, heap->elem_size);
+}
+
+static void spl_ptr_heap_zval_dtor(void *elem) { /* {{{ */
+ zval_ptr_dtor((zval *) elem);
+}
+/* }}} */
+
+static void spl_ptr_heap_zval_ctor(void *elem) { /* {{{ */
+ Z_TRY_ADDREF_P((zval *) elem);
+}
+/* }}} */
+
+static void spl_ptr_heap_pqueue_elem_dtor(void *elem) { /* {{{ */
+ spl_pqueue_elem *pq_elem = elem;
+ zval_ptr_dtor(&pq_elem->data);
+ zval_ptr_dtor(&pq_elem->priority);
}
/* }}} */
-static void spl_ptr_heap_zval_ctor(zval *elem) { /* {{{ */
- Z_TRY_ADDREF_P(elem);
+static void spl_ptr_heap_pqueue_elem_ctor(void *elem) { /* {{{ */
+ spl_pqueue_elem *pq_elem = elem;
+ Z_TRY_ADDREF_P(&pq_elem->data);
+ Z_TRY_ADDREF_P(&pq_elem->priority);
}
/* }}} */
@@ -115,29 +141,33 @@ static int spl_ptr_heap_cmp_cb_helper(zval *object, spl_heap_object *heap_object
}
/* }}} */
-static zval *spl_pqueue_extract_helper(zval *value, int flags) /* {{{ */
+static void spl_pqueue_extract_helper(zval *result, spl_pqueue_elem *elem, int flags) /* {{{ */
{
if ((flags & SPL_PQUEUE_EXTR_BOTH) == SPL_PQUEUE_EXTR_BOTH) {
- return value;
- } else if ((flags & SPL_PQUEUE_EXTR_BOTH) > 0) {
- if ((flags & SPL_PQUEUE_EXTR_DATA) == SPL_PQUEUE_EXTR_DATA) {
- zval *data;
- if ((data = zend_hash_str_find(Z_ARRVAL_P(value), "data", sizeof("data") - 1)) != NULL) {
- return data;
- }
- } else {
- zval *priority;
- if ((priority = zend_hash_str_find(Z_ARRVAL_P(value), "priority", sizeof("priority") - 1)) != NULL) {
- return priority;
- }
- }
+ array_init(result);
+ Z_TRY_ADDREF(elem->data);
+ add_assoc_zval_ex(result, "data", sizeof("data") - 1, &elem->data);
+ Z_TRY_ADDREF(elem->priority);
+ add_assoc_zval_ex(result, "priority", sizeof("priority") - 1, &elem->priority);
+ return;
+ }
+
+ if (flags & SPL_PQUEUE_EXTR_DATA) {
+ ZVAL_COPY(result, &elem->data);
+ return;
}
- return NULL;
+ if (flags & SPL_PQUEUE_EXTR_PRIORITY) {
+ ZVAL_COPY(result, &elem->priority);
+ return;
+ }
+
+ ZEND_ASSERT(0);
}
/* }}} */
-static int spl_ptr_heap_zval_max_cmp(zval *a, zval *b, zval *object) { /* {{{ */
+static int spl_ptr_heap_zval_max_cmp(void *x, void *y, zval *object) { /* {{{ */
+ zval *a = x, *b = y;
zval result;
if (EG(exception)) {
@@ -152,7 +182,7 @@ static int spl_ptr_heap_zval_max_cmp(zval *a, zval *b, zval *object) { /* {{{ */
/* exception or call failure */
return 0;
}
- return lval > 0 ? 1 : (lval < 0 ? -1 : 0);
+ return ZEND_NORMALIZE_BOOL(lval);
}
}
@@ -161,7 +191,8 @@ static int spl_ptr_heap_zval_max_cmp(zval *a, zval *b, zval *object) { /* {{{ */
}
/* }}} */
-static int spl_ptr_heap_zval_min_cmp(zval *a, zval *b, zval *object) { /* {{{ */
+static int spl_ptr_heap_zval_min_cmp(void *x, void *y, zval *object) { /* {{{ */
+ zval *a = x, *b = y;
zval result;
if (EG(exception)) {
@@ -176,7 +207,7 @@ static int spl_ptr_heap_zval_min_cmp(zval *a, zval *b, zval *object) { /* {{{ */
/* exception or call failure */
return 0;
}
- return lval > 0 ? 1 : (lval < 0 ? -1 : 0);
+ return ZEND_NORMALIZE_BOOL(lval);
}
}
@@ -185,15 +216,12 @@ static int spl_ptr_heap_zval_min_cmp(zval *a, zval *b, zval *object) { /* {{{ */
}
/* }}} */
-static int spl_ptr_pqueue_zval_cmp(zval *a, zval *b, zval *object) { /* {{{ */
+static int spl_ptr_pqueue_elem_cmp(void *x, void *y, zval *object) { /* {{{ */
+ spl_pqueue_elem *a = x;
+ spl_pqueue_elem *b = y;
+ zval *a_priority_p = &a->priority;
+ zval *b_priority_p = &b->priority;
zval result;
- zval *a_priority_p = spl_pqueue_extract_helper(a, SPL_PQUEUE_EXTR_PRIORITY);
- zval *b_priority_p = spl_pqueue_extract_helper(b, SPL_PQUEUE_EXTR_PRIORITY);
-
- if ((!a_priority_p) || (!b_priority_p)) {
- zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
- return 0;
- }
if (EG(exception)) {
return 0;
@@ -203,11 +231,11 @@ static int spl_ptr_pqueue_zval_cmp(zval *a, zval *b, zval *object) { /* {{{ */
spl_heap_object *heap_object = Z_SPLHEAP_P(object);
if (heap_object->fptr_cmp) {
zend_long lval = 0;
- if (spl_ptr_heap_cmp_cb_helper((zval *)object, heap_object, a_priority_p, b_priority_p, &lval) == FAILURE) {
+ if (spl_ptr_heap_cmp_cb_helper(object, heap_object, a_priority_p, b_priority_p, &lval) == FAILURE) {
/* exception or call failure */
return 0;
}
- return lval > 0 ? 1 : (lval < 0 ? -1 : 0);
+ return ZEND_NORMALIZE_BOOL(lval);
}
}
@@ -216,35 +244,37 @@ static int spl_ptr_pqueue_zval_cmp(zval *a, zval *b, zval *object) { /* {{{ */
}
/* }}} */
-static spl_ptr_heap *spl_ptr_heap_init(spl_ptr_heap_cmp_func cmp, spl_ptr_heap_ctor_func ctor, spl_ptr_heap_dtor_func dtor) /* {{{ */
+static spl_ptr_heap *spl_ptr_heap_init(spl_ptr_heap_cmp_func cmp, spl_ptr_heap_ctor_func ctor, spl_ptr_heap_dtor_func dtor, size_t elem_size) /* {{{ */
{
spl_ptr_heap *heap = emalloc(sizeof(spl_ptr_heap));
heap->dtor = dtor;
heap->ctor = ctor;
heap->cmp = cmp;
- heap->elements = ecalloc(PTR_HEAP_BLOCK_SIZE, sizeof(zval));
+ heap->elements = ecalloc(PTR_HEAP_BLOCK_SIZE, elem_size);
heap->max_size = PTR_HEAP_BLOCK_SIZE;
heap->count = 0;
heap->flags = 0;
+ heap->elem_size = elem_size;
return heap;
}
/* }}} */
-static void spl_ptr_heap_insert(spl_ptr_heap *heap, zval *elem, void *cmp_userdata) { /* {{{ */
+static void spl_ptr_heap_insert(spl_ptr_heap *heap, void *elem, void *cmp_userdata) { /* {{{ */
int i;
if (heap->count+1 > heap->max_size) {
+ size_t alloc_size = heap->max_size * heap->elem_size;
/* we need to allocate more memory */
- heap->elements = erealloc(heap->elements, heap->max_size * 2 * sizeof(zval));
- memset(heap->elements + heap->max_size, 0, heap->max_size * sizeof(zval));
+ heap->elements = erealloc(heap->elements, 2 * alloc_size);
+ memset((char *) heap->elements + alloc_size, 0, alloc_size);
heap->max_size *= 2;
}
/* sifting up */
- for (i = heap->count; i > 0 && heap->cmp(&heap->elements[(i-1)/2], elem, cmp_userdata) < 0; i = (i-1)/2) {
- heap->elements[i] = heap->elements[(i-1)/2];
+ for (i = heap->count; i > 0 && heap->cmp(spl_heap_elem(heap, (i-1)/2), elem, cmp_userdata) < 0; i = (i-1)/2) {
+ spl_heap_elem_copy(heap, spl_heap_elem(heap, i), spl_heap_elem(heap, (i-1)/2));
}
heap->count++;
@@ -253,42 +283,46 @@ static void spl_ptr_heap_insert(spl_ptr_heap *heap, zval *elem, void *cmp_userda
heap->flags |= SPL_HEAP_CORRUPTED;
}
- ZVAL_COPY_VALUE(&heap->elements[i], elem);
+ spl_heap_elem_copy(heap, spl_heap_elem(heap, i), elem);
}
/* }}} */
-static zval *spl_ptr_heap_top(spl_ptr_heap *heap) { /* {{{ */
+static void *spl_ptr_heap_top(spl_ptr_heap *heap) { /* {{{ */
if (heap->count == 0) {
return NULL;
}
- return Z_ISUNDEF(heap->elements[0])? NULL : &heap->elements[0];
+ return heap->elements;
}
/* }}} */
-static void spl_ptr_heap_delete_top(spl_ptr_heap *heap, zval *elem, void *cmp_userdata) { /* {{{ */
+static int spl_ptr_heap_delete_top(spl_ptr_heap *heap, void *elem, void *cmp_userdata) { /* {{{ */
int i, j;
const int limit = (heap->count-1)/2;
- zval *bottom;
+ void *bottom;
if (heap->count == 0) {
- ZVAL_UNDEF(elem);
- return;
+ return FAILURE;
+ }
+
+ if (elem) {
+ spl_heap_elem_copy(heap, elem, spl_heap_elem(heap, 0));
+ } else {
+ heap->dtor(spl_heap_elem(heap, 0));
}
- ZVAL_COPY_VALUE(elem, &heap->elements[0]);
- bottom = &heap->elements[--heap->count];
+ bottom = spl_heap_elem(heap, --heap->count);
for (i = 0; i < limit; i = j) {
/* Find smaller child */
j = i * 2 + 1;
- if(j != heap->count && heap->cmp(&heap->elements[j+1], &heap->elements[j], cmp_userdata) > 0) {
+ if (j != heap->count && heap->cmp(spl_heap_elem(heap, j+1), spl_heap_elem(heap, j), cmp_userdata) > 0) {
j++; /* next child is bigger */
}
/* swap elements between two levels */
- if(heap->cmp(bottom, &heap->elements[j], cmp_userdata) < 0) {
- heap->elements[i] = heap->elements[j];
+ if(heap->cmp(bottom, spl_heap_elem(heap, j), cmp_userdata) < 0) {
+ spl_heap_elem_copy(heap, spl_heap_elem(heap, i), spl_heap_elem(heap, j));
} else {
break;
}
@@ -299,7 +333,8 @@ static void spl_ptr_heap_delete_top(spl_ptr_heap *heap, zval *elem, void *cmp_us
heap->flags |= SPL_HEAP_CORRUPTED;
}
- ZVAL_COPY_VALUE(&heap->elements[i], bottom);
+ spl_heap_elem_copy(heap, spl_heap_elem(heap, i), bottom);
+ return SUCCESS;
}
/* }}} */
@@ -314,12 +349,13 @@ static spl_ptr_heap *spl_ptr_heap_clone(spl_ptr_heap *from) { /* {{{ */
heap->max_size = from->max_size;
heap->count = from->count;
heap->flags = from->flags;
+ heap->elem_size = from->elem_size;
- heap->elements = safe_emalloc(sizeof(zval), from->max_size, 0);
- memcpy(heap->elements, from->elements, sizeof(zval)*from->max_size);
+ heap->elements = safe_emalloc(from->elem_size, from->max_size, 0);
+ memcpy(heap->elements, from->elements, from->elem_size * from->max_size);
- for (i=0; i < heap->count; ++i) {
- heap->ctor(&heap->elements[i]);
+ for (i = 0; i < heap->count; ++i) {
+ heap->ctor(spl_heap_elem(heap, i));
}
return heap;
@@ -329,8 +365,8 @@ static spl_ptr_heap *spl_ptr_heap_clone(spl_ptr_heap *from) { /* {{{ */
static void spl_ptr_heap_destroy(spl_ptr_heap *heap) { /* {{{ */
int i;
- for (i=0; i < heap->count; ++i) {
- heap->dtor(&heap->elements[i]);
+ for (i = 0; i < heap->count; ++i) {
+ heap->dtor(spl_heap_elem(heap, i));
}
efree(heap->elements);
@@ -366,11 +402,9 @@ static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval *o
zend_object_std_init(&intern->std, class_type);
object_properties_init(&intern->std, class_type);
- intern->flags = 0;
- intern->fptr_cmp = NULL;
-
if (orig) {
spl_heap_object *other = Z_SPLHEAP_P(orig);
+ intern->std.handlers = other->std.handlers;
intern->ce_get_iterator = other->ce_get_iterator;
if (clone_orig) {
@@ -380,31 +414,25 @@ static zend_object *spl_heap_object_new_ex(zend_class_entry *class_type, zval *o
}
intern->flags = other->flags;
- } else {
- intern->heap = spl_ptr_heap_init(spl_ptr_heap_zval_max_cmp, spl_ptr_heap_zval_ctor, spl_ptr_heap_zval_dtor);
+ intern->fptr_cmp = other->fptr_cmp;
+ intern->fptr_count = other->fptr_count;
+ return &intern->std;
}
- intern->std.handlers = &spl_handler_SplHeap;
-
while (parent) {
if (parent == spl_ce_SplPriorityQueue) {
- intern->heap->cmp = spl_ptr_pqueue_zval_cmp;
- intern->flags = SPL_PQUEUE_EXTR_DATA;
+ intern->heap = spl_ptr_heap_init(spl_ptr_pqueue_elem_cmp, spl_ptr_heap_pqueue_elem_ctor, spl_ptr_heap_pqueue_elem_dtor, sizeof(spl_pqueue_elem));
intern->std.handlers = &spl_handler_SplPriorityQueue;
+ intern->flags = SPL_PQUEUE_EXTR_DATA;
break;
}
- if (parent == spl_ce_SplMinHeap) {
- intern->heap->cmp = spl_ptr_heap_zval_min_cmp;
- break;
- }
-
- if (parent == spl_ce_SplMaxHeap) {
- intern->heap->cmp = spl_ptr_heap_zval_max_cmp;
- break;
- }
-
- if (parent == spl_ce_SplHeap) {
+ if (parent == spl_ce_SplMinHeap || parent == spl_ce_SplMaxHeap
+ || parent == spl_ce_SplHeap) {
+ intern->heap = spl_ptr_heap_init(
+ parent == spl_ce_SplMinHeap ? spl_ptr_heap_zval_min_cmp : spl_ptr_heap_zval_max_cmp,
+ spl_ptr_heap_zval_ctor, spl_ptr_heap_zval_dtor, sizeof(zval));
+ intern->std.handlers = &spl_handler_SplHeap;
break;
}
@@ -502,9 +530,15 @@ static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zv
array_init(&heap_array);
for (i = 0; i < intern->heap->count; ++i) {
- add_index_zval(&heap_array, i, &intern->heap->elements[i]);
- if (Z_REFCOUNTED(intern->heap->elements[i])) {
- Z_ADDREF(intern->heap->elements[i]);
+ if (ce == spl_ce_SplPriorityQueue) {
+ spl_pqueue_elem *pq_elem = spl_heap_elem(intern->heap, i);
+ zval elem;
+ spl_pqueue_extract_helper(&elem, pq_elem, SPL_PQUEUE_EXTR_BOTH);
+ add_index_zval(&heap_array, i, &elem);
+ } else {
+ zval *elem = spl_heap_elem(intern->heap, i);
+ add_index_zval(&heap_array, i, elem);
+ Z_TRY_ADDREF_P(elem);
}
}
@@ -519,13 +553,24 @@ static HashTable* spl_heap_object_get_debug_info_helper(zend_class_entry *ce, zv
static HashTable *spl_heap_object_get_gc(zval *obj, zval **gc_data, int *gc_data_count) /* {{{ */
{
spl_heap_object *intern = Z_SPLHEAP_P(obj);
- *gc_data = intern->heap->elements;
+ *gc_data = (zval *) intern->heap->elements;
*gc_data_count = intern->heap->count;
return zend_std_get_properties(obj);
}
/* }}} */
+static HashTable *spl_pqueue_object_get_gc(zval *obj, zval **gc_data, int *gc_data_count) /* {{{ */
+{
+ spl_heap_object *intern = Z_SPLHEAP_P(obj);
+ *gc_data = (zval *) intern->heap->elements;
+ /* Two zvals (value and priority) per pqueue entry */
+ *gc_data_count = 2 * intern->heap->count;
+
+ return zend_std_get_properties(obj);
+}
+/* }}} */
+
static HashTable* spl_heap_object_get_debug_info(zval *obj, int *is_temp) /* {{{ */
{
return spl_heap_object_get_debug_info_helper(spl_ce_SplHeap, obj, is_temp);
@@ -543,7 +588,7 @@ static HashTable* spl_pqueue_object_get_debug_info(zval *obj, int *is_temp) /* {
SPL_METHOD(SplHeap, count)
{
zend_long count;
- spl_heap_object *intern = Z_SPLHEAP_P(getThis());
+ spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -558,7 +603,7 @@ SPL_METHOD(SplHeap, count)
Return true if the heap is empty. */
SPL_METHOD(SplHeap, isEmpty)
{
- spl_heap_object *intern = Z_SPLHEAP_P(getThis());
+ spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -579,7 +624,7 @@ SPL_METHOD(SplHeap, insert)
return;
}
- intern = Z_SPLHEAP_P(getThis());
+ intern = Z_SPLHEAP_P(ZEND_THIS);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0);
@@ -587,7 +632,7 @@ SPL_METHOD(SplHeap, insert)
}
Z_TRY_ADDREF_P(value);
- spl_ptr_heap_insert(intern->heap, value, getThis());
+ spl_ptr_heap_insert(intern->heap, value, ZEND_THIS);
RETURN_TRUE;
}
@@ -603,16 +648,14 @@ SPL_METHOD(SplHeap, extract)
return;
}
- intern = Z_SPLHEAP_P(getThis());
+ intern = Z_SPLHEAP_P(ZEND_THIS);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0);
return;
}
- spl_ptr_heap_delete_top(intern->heap, return_value, getThis());
-
- if (Z_ISUNDEF_P(return_value)) {
+ if (spl_ptr_heap_delete_top(intern->heap, return_value, ZEND_THIS) == FAILURE) {
zend_throw_exception(spl_ce_RuntimeException, "Can't extract from an empty heap", 0);
return;
}
@@ -623,28 +666,25 @@ SPL_METHOD(SplHeap, extract)
Push $value with the priority $priodiry on the priorityqueue */
SPL_METHOD(SplPriorityQueue, insert)
{
- zval *data, *priority, elem;
+ zval *data, *priority;
spl_heap_object *intern;
+ spl_pqueue_elem elem;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "zz", &data, &priority) == FAILURE) {
return;
}
- intern = Z_SPLHEAP_P(getThis());
+ intern = Z_SPLHEAP_P(ZEND_THIS);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0);
return;
}
- Z_TRY_ADDREF_P(data);
- Z_TRY_ADDREF_P(priority);
-
- array_init(&elem);
- add_assoc_zval_ex(&elem, "data", sizeof("data") - 1, data);
- add_assoc_zval_ex(&elem, "priority", sizeof("priority") - 1, priority);
+ ZVAL_COPY(&elem.data, data);
+ ZVAL_COPY(&elem.priority, priority);
- spl_ptr_heap_insert(intern->heap, &elem, getThis());
+ spl_ptr_heap_insert(intern->heap, &elem, ZEND_THIS);
RETURN_TRUE;
}
@@ -654,37 +694,27 @@ SPL_METHOD(SplPriorityQueue, insert)
extract the element out of the top of the priority queue */
SPL_METHOD(SplPriorityQueue, extract)
{
- zval value, *value_out;
+ spl_pqueue_elem elem;
spl_heap_object *intern;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- intern = Z_SPLHEAP_P(getThis());
+ intern = Z_SPLHEAP_P(ZEND_THIS);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0);
return;
}
- spl_ptr_heap_delete_top(intern->heap, &value, getThis());
-
- if (Z_ISUNDEF(value)) {
+ if (spl_ptr_heap_delete_top(intern->heap, &elem, ZEND_THIS) == FAILURE) {
zend_throw_exception(spl_ce_RuntimeException, "Can't extract from an empty heap", 0);
return;
}
- value_out = spl_pqueue_extract_helper(&value, intern->flags);
-
- if (!value_out) {
- zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
- zval_ptr_dtor(&value);
- return;
- }
-
- ZVAL_COPY_DEREF(return_value, value_out);
- zval_ptr_dtor(&value);
+ spl_pqueue_extract_helper(return_value, &elem, intern->flags);
+ spl_ptr_heap_pqueue_elem_dtor(&elem);
}
/* }}} */
@@ -692,35 +722,28 @@ SPL_METHOD(SplPriorityQueue, extract)
Peek at the top element of the priority queue */
SPL_METHOD(SplPriorityQueue, top)
{
- zval *value, *value_out;
spl_heap_object *intern;
+ spl_pqueue_elem *elem;
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- intern = Z_SPLHEAP_P(getThis());
+ intern = Z_SPLHEAP_P(ZEND_THIS);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0);
return;
}
- value = spl_ptr_heap_top(intern->heap);
+ elem = spl_ptr_heap_top(intern->heap);
- if (!value) {
+ if (!elem) {
zend_throw_exception(spl_ce_RuntimeException, "Can't peek at an empty heap", 0);
return;
}
- value_out = spl_pqueue_extract_helper(value, intern->flags);
-
- if (!value_out) {
- zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
- return;
- }
-
- ZVAL_COPY_DEREF(return_value, value_out);
+ spl_pqueue_extract_helper(return_value, elem, intern->flags);
}
/* }}} */
@@ -736,10 +759,14 @@ SPL_METHOD(SplPriorityQueue, setExtractFlags)
return;
}
- intern = Z_SPLHEAP_P(getThis());
-
- intern->flags = value & SPL_PQUEUE_EXTR_MASK;
+ value &= SPL_PQUEUE_EXTR_MASK;
+ if (!value) {
+ zend_throw_exception(spl_ce_RuntimeException, "Must specify at least one extract flag", 0);
+ return;
+ }
+ intern = Z_SPLHEAP_P(ZEND_THIS);
+ intern->flags = value;
RETURN_LONG(intern->flags);
}
/* }}} */
@@ -754,7 +781,7 @@ SPL_METHOD(SplPriorityQueue, getExtractFlags)
return;
}
- intern = Z_SPLHEAP_P(getThis());
+ intern = Z_SPLHEAP_P(ZEND_THIS);
RETURN_LONG(intern->flags);
}
@@ -770,7 +797,7 @@ SPL_METHOD(SplHeap, recoverFromCorruption)
return;
}
- intern = Z_SPLHEAP_P(getThis());
+ intern = Z_SPLHEAP_P(ZEND_THIS);
intern->heap->flags = intern->heap->flags & ~SPL_HEAP_CORRUPTED;
@@ -788,13 +815,13 @@ SPL_METHOD(SplHeap, isCorrupted)
return;
}
- intern = Z_SPLHEAP_P(getThis());
+ intern = Z_SPLHEAP_P(ZEND_THIS);
RETURN_BOOL(intern->heap->flags & SPL_HEAP_CORRUPTED);
}
/* }}} */
-/* {{{ proto bool SplPriorityQueue::compare(mixed $a, mixed $b)
+/* {{{ proto bool SplPriorityQueue::compare(mixed $value1, mixed $value2)
compare the priorities */
SPL_METHOD(SplPriorityQueue, compare)
{
@@ -819,7 +846,7 @@ SPL_METHOD(SplHeap, top)
return;
}
- intern = Z_SPLHEAP_P(getThis());
+ intern = Z_SPLHEAP_P(ZEND_THIS);
if (intern->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0);
@@ -837,7 +864,7 @@ SPL_METHOD(SplHeap, top)
}
/* }}} */
-/* {{{ proto bool SplMinHeap::compare(mixed $a, mixed $b)
+/* {{{ proto bool SplMinHeap::compare(mixed $value1, mixed $value2)
compare the values */
SPL_METHOD(SplMinHeap, compare)
{
@@ -851,7 +878,7 @@ SPL_METHOD(SplMinHeap, compare)
}
/* }}} */
-/* {{{ proto bool SplMaxHeap::compare(mixed $a, mixed $b)
+/* {{{ proto bool SplMaxHeap::compare(mixed $value1, mixed $value2)
compare the values */
SPL_METHOD(SplMaxHeap, compare)
{
@@ -889,40 +916,39 @@ static int spl_heap_it_valid(zend_object_iterator *iter) /* {{{ */
static zval *spl_heap_it_get_current_data(zend_object_iterator *iter) /* {{{ */
{
spl_heap_object *object = Z_SPLHEAP_P(&iter->data);
- zval *element = &object->heap->elements[0];
if (object->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0);
return NULL;
}
- if (object->heap->count == 0 || Z_ISUNDEF_P(element)) {
+ if (object->heap->count == 0) {
return NULL;
} else {
- return element;
+ return spl_heap_elem(object->heap, 0);
}
}
/* }}} */
static zval *spl_pqueue_it_get_current_data(zend_object_iterator *iter) /* {{{ */
{
+ zend_user_iterator *user_it = (zend_user_iterator *) iter;
spl_heap_object *object = Z_SPLHEAP_P(&iter->data);
- zval *element = &object->heap->elements[0];
if (object->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0);
return NULL;
}
- if (object->heap->count == 0 || Z_ISUNDEF_P(element)) {
+ if (object->heap->count == 0) {
return NULL;
- } else {
- zval *data = spl_pqueue_extract_helper(element, object->flags);
- if (!data) {
- zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
- }
- return data;
}
+
+ if (Z_ISUNDEF(user_it->value)) {
+ spl_pqueue_elem *elem = spl_heap_elem(object->heap, 0);
+ spl_pqueue_extract_helper(&user_it->value, elem, object->flags);
+ }
+ return &user_it->value;
}
/* }}} */
@@ -937,17 +963,13 @@ static void spl_heap_it_get_current_key(zend_object_iterator *iter, zval *key) /
static void spl_heap_it_move_forward(zend_object_iterator *iter) /* {{{ */
{
spl_heap_object *object = Z_SPLHEAP_P(&iter->data);
- zval elem;
if (object->heap->flags & SPL_HEAP_CORRUPTED) {
zend_throw_exception(spl_ce_RuntimeException, "Heap is corrupted, heap properties are no longer ensured.", 0);
return;
}
- spl_ptr_heap_delete_top(object->heap, &elem, &iter->data);
-
- zval_ptr_dtor(&elem);
-
+ spl_ptr_heap_delete_top(object->heap, NULL, &iter->data);
zend_user_it_invalidate_current(iter);
}
/* }}} */
@@ -956,7 +978,7 @@ static void spl_heap_it_move_forward(zend_object_iterator *iter) /* {{{ */
Return current array key */
SPL_METHOD(SplHeap, key)
{
- spl_heap_object *intern = Z_SPLHEAP_P(getThis());
+ spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -970,15 +992,13 @@ SPL_METHOD(SplHeap, key)
Move to next entry */
SPL_METHOD(SplHeap, next)
{
- spl_heap_object *intern = Z_SPLHEAP_P(getThis());
- zval elem;
- spl_ptr_heap_delete_top(intern->heap, &elem, getThis());
+ spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- zval_ptr_dtor(&elem);
+ spl_ptr_heap_delete_top(intern->heap, NULL, ZEND_THIS);
}
/* }}} */
@@ -986,7 +1006,7 @@ SPL_METHOD(SplHeap, next)
Check whether the datastructure contains more entries */
SPL_METHOD(SplHeap, valid)
{
- spl_heap_object *intern = Z_SPLHEAP_P(getThis());
+ spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1011,16 +1031,16 @@ SPL_METHOD(SplHeap, rewind)
Return current datastructure entry */
SPL_METHOD(SplHeap, current)
{
- spl_heap_object *intern = Z_SPLHEAP_P(getThis());
- zval *element = &intern->heap->elements[0];
+ spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- if (!intern->heap->count || Z_ISUNDEF_P(element)) {
+ if (!intern->heap->count) {
RETURN_NULL();
} else {
+ zval *element = spl_heap_elem(intern->heap, 0);
ZVAL_COPY_DEREF(return_value, element);
}
}
@@ -1030,24 +1050,17 @@ SPL_METHOD(SplHeap, current)
Return current datastructure entry */
SPL_METHOD(SplPriorityQueue, current)
{
- spl_heap_object *intern = Z_SPLHEAP_P(getThis());
- zval *element = &intern->heap->elements[0];
+ spl_heap_object *intern = Z_SPLHEAP_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- if (!intern->heap->count || Z_ISUNDEF_P(element)) {
+ if (!intern->heap->count) {
RETURN_NULL();
} else {
- zval *data = spl_pqueue_extract_helper(element, intern->flags);
-
- if (!data) {
- zend_error(E_RECOVERABLE_ERROR, "Unable to extract from the PriorityQueue node");
- RETURN_NULL();
- }
-
- ZVAL_COPY_DEREF(return_value, data);
+ spl_pqueue_elem *elem = spl_heap_elem(intern->heap, 0);
+ spl_pqueue_extract_helper(return_value, elem, intern->flags);
}
}
/* }}} */
@@ -1087,7 +1100,8 @@ zend_object_iterator *spl_heap_get_iterator(zend_class_entry *ce, zval *object,
zend_iterator_init(&iterator->intern.it);
- ZVAL_COPY(&iterator->intern.it.data, object);
+ Z_ADDREF_P(object);
+ ZVAL_OBJ(&iterator->intern.it.data, Z_OBJ_P(object));
iterator->intern.it.funcs = &spl_heap_it_funcs;
iterator->intern.ce = ce;
iterator->flags = heap_object->flags;
@@ -1111,7 +1125,8 @@ zend_object_iterator *spl_pqueue_get_iterator(zend_class_entry *ce, zval *object
zend_iterator_init((zend_object_iterator*)iterator);
- ZVAL_COPY(&iterator->intern.it.data, object);
+ Z_ADDREF_P(object);
+ ZVAL_OBJ(&iterator->intern.it.data, Z_OBJ_P(object));
iterator->intern.it.funcs = &spl_pqueue_it_funcs;
iterator->intern.ce = ce;
iterator->flags = heap_object->flags;
@@ -1127,8 +1142,8 @@ ZEND_BEGIN_ARG_INFO(arginfo_heap_insert, 0)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_heap_compare, 0)
- ZEND_ARG_INFO(0, a)
- ZEND_ARG_INFO(0, b)
+ ZEND_ARG_INFO(0, value1)
+ ZEND_ARG_INFO(0, value2)
ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO(arginfo_pqueue_insert, 0)
@@ -1220,7 +1235,7 @@ PHP_MINIT_FUNCTION(spl_heap) /* {{{ */
spl_handler_SplPriorityQueue.clone_obj = spl_heap_object_clone;
spl_handler_SplPriorityQueue.count_elements = spl_heap_object_count_elements;
spl_handler_SplPriorityQueue.get_debug_info = spl_pqueue_object_get_debug_info;
- spl_handler_SplPriorityQueue.get_gc = spl_heap_object_get_gc;
+ spl_handler_SplPriorityQueue.get_gc = spl_pqueue_object_get_gc;
spl_handler_SplPriorityQueue.dtor_obj = zend_objects_destroy_object;
spl_handler_SplPriorityQueue.free_obj = spl_heap_object_free_storage;
@@ -1236,12 +1251,3 @@ PHP_MINIT_FUNCTION(spl_heap) /* {{{ */
return SUCCESS;
}
/* }}} */
-
-/*
- * 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_heap.h b/ext/spl/spl_heap.h
index d0d7718411..d73fca545e 100644
--- a/ext/spl/spl_heap.h
+++ b/ext/spl/spl_heap.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -31,12 +31,3 @@ extern PHPAPI zend_class_entry *spl_ce_SplPriorityQueue;
PHP_MINIT_FUNCTION(spl_heap);
#endif /* SPL_HEAP_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/spl_iterators.c b/ext/spl/spl_iterators.c
index 23fa58a4b1..cce9477ed5 100644
--- a/ext/spl/spl_iterators.c
+++ b/ext/spl/spl_iterators.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -469,14 +469,15 @@ static zend_object_iterator *spl_recursive_it_get_iterator(zend_class_entry *ce,
zend_iterator_init((zend_object_iterator*)iterator);
- ZVAL_COPY(&iterator->intern.data, zobject);
+ Z_ADDREF_P(zobject);
+ ZVAL_OBJ(&iterator->intern.data, Z_OBJ_P(zobject));
iterator->intern.funcs = &spl_recursive_it_iterator_funcs;
return (zend_object_iterator*)iterator;
}
static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_class_entry *ce_base, zend_class_entry *ce_inner, recursive_it_it_type rit_type)
{
- zval *object = getThis();
+ zval *object = ZEND_THIS;
spl_recursive_it_object *intern;
zval *iterator;
zend_class_entry *ce_iterator;
@@ -582,7 +583,7 @@ static void spl_recursive_it_it_construct(INTERNAL_FUNCTION_PARAMETERS, zend_cla
ce_iterator = Z_OBJCE_P(iterator); /* respect inheritance, don't use spl_ce_RecursiveIterator */
intern->iterators[0].iterator = ce_iterator->get_iterator(ce_iterator, iterator, 0);
- ZVAL_COPY_VALUE(&intern->iterators[0].zobject, iterator);
+ ZVAL_OBJ(&intern->iterators[0].zobject, Z_OBJ_P(iterator));
intern->iterators[0].ce = ce_iterator;
intern->iterators[0].state = RS_START;
@@ -612,33 +613,33 @@ SPL_METHOD(RecursiveIteratorIterator, __construct)
Rewind the iterator to the first element of the top level inner iterator. */
SPL_METHOD(RecursiveIteratorIterator, rewind)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- spl_recursive_it_rewind_ex(object, getThis());
+ spl_recursive_it_rewind_ex(object, ZEND_THIS);
} /* }}} */
/* {{{ proto bool RecursiveIteratorIterator::valid()
Check whether the current position is valid */
SPL_METHOD(RecursiveIteratorIterator, valid)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- RETURN_BOOL(spl_recursive_it_valid_ex(object, getThis()) == SUCCESS);
+ RETURN_BOOL(spl_recursive_it_valid_ex(object, ZEND_THIS) == SUCCESS);
} /* }}} */
/* {{{ proto mixed RecursiveIteratorIterator::key()
Access the current key */
SPL_METHOD(RecursiveIteratorIterator, key)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
zend_object_iterator *iterator;
if (zend_parse_parameters_none() == FAILURE) {
@@ -658,7 +659,7 @@ SPL_METHOD(RecursiveIteratorIterator, key)
Access the current element value */
SPL_METHOD(RecursiveIteratorIterator, current)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
zend_object_iterator *iterator;
zval *data;
@@ -678,20 +679,20 @@ SPL_METHOD(RecursiveIteratorIterator, current)
Move forward to the next element */
SPL_METHOD(RecursiveIteratorIterator, next)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
}
- spl_recursive_it_move_forward_ex(object, getThis());
+ spl_recursive_it_move_forward_ex(object, ZEND_THIS);
} /* }}} */
/* {{{ proto int RecursiveIteratorIterator::getDepth()
Get the current depth of the recursive iteration */
SPL_METHOD(RecursiveIteratorIterator, getDepth)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -704,7 +705,7 @@ SPL_METHOD(RecursiveIteratorIterator, getDepth)
The current active sub iterator or the iterator at specified level */
SPL_METHOD(RecursiveIteratorIterator, getSubIterator)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
zend_long level = object->level;
zval *value;
@@ -729,7 +730,7 @@ SPL_METHOD(RecursiveIteratorIterator, getSubIterator)
The current active sub iterator */
SPL_METHOD(RecursiveIteratorIterator, getInnerIterator)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
zval *zobject;
if (zend_parse_parameters_none() == FAILURE) {
@@ -765,7 +766,7 @@ SPL_METHOD(RecursiveIteratorIterator, endIteration)
Called for each element to test whether it has children */
SPL_METHOD(RecursiveIteratorIterator, callHasChildren)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
zend_class_entry *ce;
zval *zobject;
@@ -794,7 +795,7 @@ SPL_METHOD(RecursiveIteratorIterator, callHasChildren)
Return children of current element */
SPL_METHOD(RecursiveIteratorIterator, callGetChildren)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
zend_class_entry *ce;
zval *zobject;
@@ -849,7 +850,7 @@ SPL_METHOD(RecursiveIteratorIterator, nextElement)
Set the maximum allowed depth (or any depth if pmax_depth = -1] */
SPL_METHOD(RecursiveIteratorIterator, setMaxDepth)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
zend_long max_depth = -1;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &max_depth) == FAILURE) {
@@ -869,7 +870,7 @@ SPL_METHOD(RecursiveIteratorIterator, setMaxDepth)
Return the maximum accepted depth or false if any depth is allowed */
SPL_METHOD(RecursiveIteratorIterator, getMaxDepth)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -882,9 +883,9 @@ SPL_METHOD(RecursiveIteratorIterator, getMaxDepth)
}
} /* }}} */
-static union _zend_function *spl_recursive_it_get_method(zend_object **zobject, zend_string *method, const zval *key)
+static zend_function *spl_recursive_it_get_method(zend_object **zobject, zend_string *method, const zval *key)
{
- union _zend_function *function_handler;
+ zend_function *function_handler;
spl_recursive_it_object *object = spl_recursive_it_from_obj(*zobject);
zend_long level = object->level;
zval *zobj;
@@ -897,10 +898,8 @@ static union _zend_function *spl_recursive_it_get_method(zend_object **zobject,
function_handler = zend_std_get_method(zobject, method, key);
if (!function_handler) {
if ((function_handler = zend_hash_find_ptr(&Z_OBJCE_P(zobj)->function_table, method)) == NULL) {
- if (Z_OBJ_HT_P(zobj)->get_method) {
- *zobject = Z_OBJ_P(zobj);
- function_handler = (*zobject)->handlers->get_method(zobject, method, key);
- }
+ *zobject = Z_OBJ_P(zobj);
+ function_handler = (*zobject)->handlers->get_method(zobject, method, key);
} else {
*zobject = Z_OBJ_P(zobj);
}
@@ -1067,23 +1066,18 @@ static void spl_recursive_tree_iterator_get_entry(spl_recursive_it_object *objec
{
zend_object_iterator *iterator = object->iterators[object->level].iterator;
zval *data;
- zend_error_handling error_handling;
data = iterator->funcs->get_current_data(iterator);
-
- /* Replace exception handling so the catchable fatal error that is thrown when a class
- * without __toString is converted to string is converted into an exception. */
- zend_replace_error_handling(EH_THROW, spl_ce_UnexpectedValueException, &error_handling);
if (data) {
ZVAL_DEREF(data);
+ /* TODO: Remove this special case? */
if (Z_TYPE_P(data) == IS_ARRAY) {
- ZVAL_STRINGL(return_value, "Array", sizeof("Array")-1);
+ RETVAL_INTERNED_STR(ZSTR_KNOWN(ZEND_STR_ARRAY_CAPITALIZED));
} else {
ZVAL_COPY(return_value, data);
convert_to_string(return_value);
}
}
- zend_restore_error_handling(&error_handling);
}
static void spl_recursive_tree_iterator_get_postfix(spl_recursive_it_object *object, zval *return_value)
@@ -1106,7 +1100,7 @@ SPL_METHOD(RecursiveTreeIterator, setPrefixPart)
zend_long part;
char* prefix;
size_t prefix_len;
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "ls", &part, &prefix, &prefix_len) == FAILURE) {
return;
@@ -1125,7 +1119,7 @@ SPL_METHOD(RecursiveTreeIterator, setPrefixPart)
Returns the string to place in front of current element */
SPL_METHOD(RecursiveTreeIterator, getPrefix)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1144,7 +1138,7 @@ SPL_METHOD(RecursiveTreeIterator, getPrefix)
Sets postfix as used in getPostfix() */
SPL_METHOD(RecursiveTreeIterator, setPostfix)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
char* postfix;
size_t postfix_len;
@@ -1160,7 +1154,7 @@ SPL_METHOD(RecursiveTreeIterator, setPostfix)
Returns the string presentation built for current element */
SPL_METHOD(RecursiveTreeIterator, getEntry)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1179,7 +1173,7 @@ SPL_METHOD(RecursiveTreeIterator, getEntry)
Returns the string to place after the current element */
SPL_METHOD(RecursiveTreeIterator, getPostfix)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1198,7 +1192,7 @@ SPL_METHOD(RecursiveTreeIterator, getPostfix)
Returns the current element prefixed and postfixed */
SPL_METHOD(RecursiveTreeIterator, current)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
zval prefix, entry, postfix;
char *ptr;
zend_string *str;
@@ -1260,7 +1254,7 @@ SPL_METHOD(RecursiveTreeIterator, current)
Returns the current key prefixed and postfixed */
SPL_METHOD(RecursiveTreeIterator, key)
{
- spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(getThis());
+ spl_recursive_it_object *object = Z_SPLRECURSIVE_IT_P(ZEND_THIS);
zend_object_iterator *iterator;
zval prefix, key, postfix, key_copy;
char *ptr;
@@ -1348,22 +1342,9 @@ static const zend_function_entry spl_funcs_RecursiveTreeIterator[] = {
PHP_FE_END
};
-#if MBO_0
-static int spl_dual_it_gets_implemented(zend_class_entry *interface, zend_class_entry *class_type)
+static zend_function *spl_dual_it_get_method(zend_object **object, zend_string *method, const zval *key)
{
- class_type->iterator_funcs_ptr->zf_valid = NULL;
- class_type->iterator_funcs_ptr->zf_current = NULL;
- class_type->iterator_funcs_ptr->zf_key = NULL;
- class_type->iterator_funcs_ptr->zf_next = NULL;
- class_type->iterator_funcs_ptr->zf_rewind = NULL;
-
- return SUCCESS;
-}
-#endif
-
-static union _zend_function *spl_dual_it_get_method(zend_object **object, zend_string *method, const zval *key)
-{
- union _zend_function *function_handler;
+ zend_function *function_handler;
spl_dual_it_object *intern;
intern = spl_dual_it_from_obj(*object);
@@ -1393,7 +1374,7 @@ int spl_dual_it_call_method(char *method, INTERNAL_FUNCTION_PARAMETERS)
void **p;
spl_dual_it_object *intern;
- intern = Z_SPLDUAL_IT_P(getThis());
+ intern = Z_SPLDUAL_IT_P(ZEND_THIS);
ZVAL_STRING(&func, method, 0);
@@ -1454,7 +1435,7 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
int inc_refcount = 1;
zend_error_handling error_handling;
- intern = Z_SPLDUAL_IT_P(getThis());
+ intern = Z_SPLDUAL_IT_P(ZEND_THIS);
if (intern->dit_type != DIT_Unknown) {
zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s::getIterator() must be called exactly once per instance", ZSTR_VAL(ce_base->name));
@@ -1536,7 +1517,6 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
intern->u.append.iterator = spl_ce_ArrayIterator->get_iterator(spl_ce_ArrayIterator, &intern->u.append.zarrayit, 0);
zend_restore_error_handling(&error_handling);
return intern;
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
case DIT_RegexIterator:
case DIT_RecursiveRegexIterator: {
zend_string *regex;
@@ -1566,7 +1546,6 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
php_pcre_pce_incref(intern->u.regex.pce);
break;
}
-#endif
case DIT_CallbackFilterIterator:
case DIT_RecursiveCallbackFilterIterator: {
_spl_cbfilter_it_intern *cfi = emalloc(sizeof(*cfi));
@@ -1589,9 +1568,9 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z
}
if (inc_refcount) {
- Z_TRY_ADDREF_P(zobject);
+ Z_ADDREF_P(zobject);
}
- ZVAL_COPY_VALUE(&intern->inner.zobject, zobject);
+ ZVAL_OBJ(&intern->inner.zobject, Z_OBJ_P(zobject));
intern->inner.ce = dit_type == DIT_IteratorIterator ? ce : Z_OBJCE_P(zobject);
intern->inner.object = Z_OBJ_P(zobject);
@@ -1627,7 +1606,7 @@ SPL_METHOD(dual_it, getInnerIterator)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (!Z_ISUNDEF(intern->inner.zobject)) {
zval *value = &intern->inner.zobject;
@@ -1730,7 +1709,7 @@ SPL_METHOD(dual_it, rewind)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
spl_dual_it_rewind(intern);
spl_dual_it_fetch(intern, 1);
@@ -1749,7 +1728,7 @@ SPL_METHOD(dual_it, valid)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
RETURN_BOOL(Z_TYPE(intern->current.data) != IS_UNDEF);
} /* }}} */
@@ -1770,7 +1749,7 @@ SPL_METHOD(dual_it, key)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (Z_TYPE(intern->current.key) != IS_UNDEF) {
zval *value = &intern->current.key;
@@ -1796,7 +1775,7 @@ SPL_METHOD(dual_it, current)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (Z_TYPE(intern->current.data) != IS_UNDEF) {
zval *value = &intern->current.data;
@@ -1819,7 +1798,7 @@ SPL_METHOD(dual_it, next)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
spl_dual_it_next(intern, 1);
spl_dual_it_fetch(intern, 1);
@@ -1868,8 +1847,8 @@ SPL_METHOD(FilterIterator, rewind)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
- spl_filter_it_rewind(getThis(), intern);
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
+ spl_filter_it_rewind(ZEND_THIS, intern);
} /* }}} */
/* {{{ proto void FilterIterator::next()
@@ -1882,8 +1861,8 @@ SPL_METHOD(FilterIterator, next)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
- spl_filter_it_next(getThis(), intern);
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
+ spl_filter_it_next(ZEND_THIS, intern);
} /* }}} */
/* {{{ proto RecursiveCallbackFilterIterator::__construct(RecursiveIterator it, callback func)
@@ -1912,7 +1891,7 @@ SPL_METHOD(RecursiveFilterIterator, hasChildren)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "haschildren", &retval);
if (Z_TYPE(retval) != IS_UNDEF) {
@@ -1933,11 +1912,11 @@ SPL_METHOD(RecursiveFilterIterator, getChildren)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception) && Z_TYPE(retval) != IS_UNDEF) {
- spl_instantiate_arg_ex1(Z_OBJCE_P(getThis()), return_value, &retval);
+ spl_instantiate_arg_ex1(Z_OBJCE_P(ZEND_THIS), return_value, &retval);
}
zval_ptr_dtor(&retval);
} /* }}} */
@@ -1953,11 +1932,11 @@ SPL_METHOD(RecursiveCallbackFilterIterator, getChildren)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception) && Z_TYPE(retval) != IS_UNDEF) {
- spl_instantiate_arg_ex2(Z_OBJCE_P(getThis()), return_value, &retval, &intern->u.cbfilter->fci.function_name);
+ spl_instantiate_arg_ex2(Z_OBJCE_P(ZEND_THIS), return_value, &retval, &intern->u.cbfilter->fci.function_name);
}
zval_ptr_dtor(&retval);
} /* }}} */
@@ -1968,7 +1947,6 @@ SPL_METHOD(ParentIterator, __construct)
spl_dual_it_construct(INTERNAL_FUNCTION_PARAM_PASSTHRU, spl_ce_ParentIterator, spl_ce_RecursiveIterator, DIT_ParentIterator);
} /* }}} */
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
/* {{{ proto RegexIterator::__construct(Iterator it, string regex [, int mode [, int flags [, int preg_flags]]])
Create an RegexIterator from another iterator and a regular expression */
SPL_METHOD(RegexIterator, __construct)
@@ -1980,7 +1958,7 @@ SPL_METHOD(RegexIterator, __construct)
Calls the callback with the current value, the current key and the inner iterator as arguments */
SPL_METHOD(CallbackFilterIterator, accept)
{
- spl_dual_it_object *intern = Z_SPLDUAL_IT_P(getThis());
+ spl_dual_it_object *intern = Z_SPLDUAL_IT_P(ZEND_THIS);
zend_fcall_info *fci = &intern->u.cbfilter->fci;
zend_fcall_info_cache *fcc = &intern->u.cbfilter->fcc;
zval params[3];
@@ -2023,7 +2001,7 @@ SPL_METHOD(RegexIterator, accept)
spl_dual_it_object *intern;
zend_string *result, *subject;
size_t count = 0;
- zval zcount, *replacement, tmp_replacement, rv;
+ zval zcount, rv;
pcre2_match_data *match_data;
pcre2_code *re;
int rc;
@@ -2032,7 +2010,7 @@ SPL_METHOD(RegexIterator, accept)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (Z_TYPE(intern->current.data) == IS_UNDEF) {
RETURN_FALSE;
@@ -2047,6 +2025,11 @@ SPL_METHOD(RegexIterator, accept)
subject = zval_get_string(&intern->current.data);
}
+ /* Exception during string conversion. */
+ if (EG(exception)) {
+ return;
+ }
+
switch (intern->u.regex.mode)
{
case REGIT_MODE_MAX: /* won't happen but makes compiler happy */
@@ -2065,7 +2048,7 @@ SPL_METHOD(RegexIterator, accept)
case REGIT_MODE_GET_MATCH:
zval_ptr_dtor(&intern->current.data);
ZVAL_UNDEF(&intern->current.data);
- php_pcre_match_impl(intern->u.regex.pce, ZSTR_VAL(subject), ZSTR_LEN(subject), &zcount,
+ php_pcre_match_impl(intern->u.regex.pce, subject, &zcount,
&intern->current.data, intern->u.regex.mode == REGIT_MODE_ALL_MATCHES, intern->u.regex.use_flags, intern->u.regex.preg_flags, 0);
RETVAL_BOOL(Z_LVAL(zcount) > 0);
break;
@@ -2078,14 +2061,14 @@ SPL_METHOD(RegexIterator, accept)
RETVAL_BOOL(count > 1);
break;
- case REGIT_MODE_REPLACE:
- replacement = zend_read_property(intern->std.ce, getThis(), "replacement", sizeof("replacement")-1, 1, &rv);
- if (Z_TYPE_P(replacement) != IS_STRING) {
- ZVAL_COPY(&tmp_replacement, replacement);
- convert_to_string(&tmp_replacement);
- replacement = &tmp_replacement;
+ case REGIT_MODE_REPLACE: {
+ zval *replacement = zend_read_property(intern->std.ce, ZEND_THIS, "replacement", sizeof("replacement")-1, 1, &rv);
+ zend_string *replacement_str = zval_try_get_string(replacement);
+ if (UNEXPECTED(!replacement_str)) {
+ return;
}
- result = php_pcre_replace_impl(intern->u.regex.pce, subject, ZSTR_VAL(subject), ZSTR_LEN(subject), Z_STR_P(replacement), -1, &count);
+
+ result = php_pcre_replace_impl(intern->u.regex.pce, subject, ZSTR_VAL(subject), ZSTR_LEN(subject), replacement_str, -1, &count);
if (intern->u.regex.flags & REGIT_USE_KEY) {
zval_ptr_dtor(&intern->current.key);
@@ -2095,10 +2078,9 @@ SPL_METHOD(RegexIterator, accept)
ZVAL_STR(&intern->current.data, result);
}
- if (replacement == &tmp_replacement) {
- zval_ptr_dtor(replacement);
- }
+ zend_string_release(replacement_str);
RETVAL_BOOL(count > 0);
+ }
}
if (intern->u.regex.flags & REGIT_INVERTED) {
@@ -2111,7 +2093,7 @@ SPL_METHOD(RegexIterator, accept)
Returns current regular expression */
SPL_METHOD(RegexIterator, getRegex)
{
- spl_dual_it_object *intern = Z_SPLDUAL_IT_P(getThis());
+ spl_dual_it_object *intern = Z_SPLDUAL_IT_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -2130,7 +2112,7 @@ SPL_METHOD(RegexIterator, getMode)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
RETURN_LONG(intern->u.regex.mode);
} /* }}} */
@@ -2151,7 +2133,7 @@ SPL_METHOD(RegexIterator, setMode)
return;/* NULL */
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
intern->u.regex.mode = mode;
} /* }}} */
@@ -2166,7 +2148,7 @@ SPL_METHOD(RegexIterator, getFlags)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
RETURN_LONG(intern->u.regex.flags);
} /* }}} */
@@ -2182,7 +2164,7 @@ SPL_METHOD(RegexIterator, setFlags)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
intern->u.regex.flags = flags;
} /* }}} */
@@ -2197,7 +2179,7 @@ SPL_METHOD(RegexIterator, getPregFlags)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (intern->u.regex.use_flags) {
RETURN_LONG(intern->u.regex.preg_flags);
@@ -2217,7 +2199,7 @@ SPL_METHOD(RegexIterator, setPregFlags)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
intern->u.regex.preg_flags = preg_flags;
intern->u.regex.use_flags = 1;
@@ -2241,7 +2223,7 @@ SPL_METHOD(RecursiveRegexIterator, getChildren)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
zend_call_method_with_0_params(&intern->inner.zobject, intern->inner.ce, NULL, "getchildren", &retval);
if (!EG(exception)) {
@@ -2253,7 +2235,7 @@ SPL_METHOD(RecursiveRegexIterator, getChildren)
ZVAL_LONG(&args[3], intern->u.regex.flags);
ZVAL_LONG(&args[4], intern->u.regex.preg_flags);
- spl_instantiate_arg_n(Z_OBJCE_P(getThis()), return_value, 5, args);
+ spl_instantiate_arg_n(Z_OBJCE_P(ZEND_THIS), return_value, 5, args);
zval_ptr_dtor(&args[0]);
zval_ptr_dtor(&args[1]);
@@ -2269,7 +2251,7 @@ SPL_METHOD(RecursiveRegexIterator, accept)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (Z_TYPE(intern->current.data) == IS_UNDEF) {
RETURN_FALSE;
@@ -2277,11 +2259,9 @@ SPL_METHOD(RecursiveRegexIterator, accept)
RETURN_BOOL(zend_hash_num_elements(Z_ARRVAL(intern->current.data)) > 0);
}
- zend_call_method_with_0_params(getThis(), spl_ce_RegexIterator, NULL, "accept", return_value);
+ zend_call_method_with_0_params(ZEND_THIS, spl_ce_RegexIterator, NULL, "accept", return_value);
}
-#endif
-
/* {{{ spl_dual_it_dtor */
static void spl_dual_it_dtor(zend_object *_object)
{
@@ -2319,7 +2299,6 @@ static void spl_dual_it_free_storage(zend_object *_object)
zval_ptr_dtor(&object->u.caching.zcache);
}
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
if (object->dit_type == DIT_RegexIterator || object->dit_type == DIT_RecursiveRegexIterator) {
if (object->u.regex.pce) {
php_pcre_pce_decref(object->u.regex.pce);
@@ -2328,7 +2307,6 @@ static void spl_dual_it_free_storage(zend_object *_object)
zend_string_release_ex(object->u.regex.regex, 0);
}
}
-#endif
if (object->dit_type == DIT_CallbackFilterIterator || object->dit_type == DIT_RecursiveCallbackFilterIterator) {
if (object->u.cbfilter) {
@@ -2418,7 +2396,6 @@ static const zend_function_entry spl_funcs_ParentIterator[] = {
PHP_FE_END
};
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
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)
@@ -2467,7 +2444,6 @@ static const zend_function_entry spl_funcs_RecursiveRegexIterator[] = {
SPL_ME(RecursiveRegexIterator, getChildren, arginfo_recursive_it_void, ZEND_ACC_PUBLIC)
PHP_FE_END
};
-#endif
static inline int spl_limit_it_valid(spl_dual_it_object *intern)
{
@@ -2530,7 +2506,7 @@ SPL_METHOD(LimitIterator, rewind)
{
spl_dual_it_object *intern;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
spl_dual_it_rewind(intern);
spl_limit_it_seek(intern, intern->u.limit.offset);
} /* }}} */
@@ -2541,7 +2517,7 @@ SPL_METHOD(LimitIterator, valid)
{
spl_dual_it_object *intern;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
/* RETURN_BOOL(spl_limit_it_valid(intern) == SUCCESS);*/
RETURN_BOOL((intern->u.limit.count == -1 || intern->current.pos < intern->u.limit.offset + intern->u.limit.count) && Z_TYPE(intern->current.data) != IS_UNDEF);
@@ -2553,7 +2529,7 @@ SPL_METHOD(LimitIterator, next)
{
spl_dual_it_object *intern;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
spl_dual_it_next(intern, 1);
if (intern->u.limit.count == -1 || intern->current.pos < intern->u.limit.offset + intern->u.limit.count) {
@@ -2572,7 +2548,7 @@ SPL_METHOD(LimitIterator, seek)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
spl_limit_it_seek(intern, pos);
RETURN_LONG(intern->current.pos);
} /* }}} */
@@ -2582,12 +2558,12 @@ SPL_METHOD(LimitIterator, seek)
SPL_METHOD(LimitIterator, getPosition)
{
spl_dual_it_object *intern;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
RETURN_LONG(intern->current.pos);
} /* }}} */
ZEND_BEGIN_ARG_INFO(arginfo_seekable_it_seek, 0)
- ZEND_ARG_INFO(0, position)
+ ZEND_ARG_TYPE_INFO(0, position, IS_LONG, 0)
ZEND_END_ARG_INFO();
static const zend_function_entry spl_funcs_SeekableIterator[] = {
@@ -2725,7 +2701,7 @@ SPL_METHOD(CachingIterator, rewind)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
spl_caching_it_rewind(intern);
} /* }}} */
@@ -2740,7 +2716,7 @@ SPL_METHOD(CachingIterator, valid)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
RETURN_BOOL(spl_caching_it_valid(intern) == SUCCESS);
} /* }}} */
@@ -2755,7 +2731,7 @@ SPL_METHOD(CachingIterator, next)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
spl_caching_it_next(intern);
} /* }}} */
@@ -2770,7 +2746,7 @@ SPL_METHOD(CachingIterator, hasNext)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
RETURN_BOOL(spl_caching_it_has_next(intern) == SUCCESS);
} /* }}} */
@@ -2781,10 +2757,10 @@ SPL_METHOD(CachingIterator, __toString)
{
spl_dual_it_object *intern;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (!(intern->u.caching.flags & (CIT_CALL_TOSTRING|CIT_TOSTRING_USE_KEY|CIT_TOSTRING_USE_CURRENT|CIT_TOSTRING_USE_INNER))) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not fetch string value (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name));
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not fetch string value (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name));
return;
}
if (intern->u.caching.flags & CIT_TOSTRING_USE_KEY) {
@@ -2811,10 +2787,10 @@ SPL_METHOD(CachingIterator, offsetSet)
zend_string *key;
zval *value;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (!(intern->u.caching.flags & CIT_FULL_CACHE)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name));
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name));
return;
}
@@ -2835,10 +2811,10 @@ SPL_METHOD(CachingIterator, offsetGet)
zend_string *key;
zval *value;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (!(intern->u.caching.flags & CIT_FULL_CACHE)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name));
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name));
return;
}
@@ -2862,10 +2838,10 @@ SPL_METHOD(CachingIterator, offsetUnset)
spl_dual_it_object *intern;
zend_string *key;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (!(intern->u.caching.flags & CIT_FULL_CACHE)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name));
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name));
return;
}
@@ -2884,10 +2860,10 @@ SPL_METHOD(CachingIterator, offsetExists)
spl_dual_it_object *intern;
zend_string *key;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (!(intern->u.caching.flags & CIT_FULL_CACHE)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name));
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name));
return;
}
@@ -2909,10 +2885,10 @@ SPL_METHOD(CachingIterator, getCache)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (!(intern->u.caching.flags & CIT_FULL_CACHE)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name));
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name));
return;
}
@@ -2930,7 +2906,7 @@ SPL_METHOD(CachingIterator, getFlags)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
RETURN_LONG(intern->u.caching.flags);
}
@@ -2943,7 +2919,7 @@ SPL_METHOD(CachingIterator, setFlags)
spl_dual_it_object *intern;
zend_long flags;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &flags) == FAILURE) {
return;
@@ -2979,10 +2955,10 @@ SPL_METHOD(CachingIterator, count)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (!(intern->u.caching.flags & CIT_FULL_CACHE)) {
- zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(getThis())->name));
+ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "%s does not use a full cache (see CachingIterator::__construct)", ZSTR_VAL(Z_OBJCE_P(ZEND_THIS)->name));
return;
}
@@ -3046,7 +3022,7 @@ SPL_METHOD(RecursiveCachingIterator, hasChildren)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
RETURN_BOOL(Z_TYPE(intern->u.caching.zchildren) != IS_UNDEF);
} /* }}} */
@@ -3061,7 +3037,7 @@ SPL_METHOD(RecursiveCachingIterator, getChildren)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (Z_TYPE(intern->u.caching.zchildren) != IS_UNDEF) {
zval *value = &intern->u.caching.zchildren;
@@ -3133,7 +3109,7 @@ SPL_METHOD(NoRewindIterator, valid)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
RETURN_BOOL(intern->inner.iterator->funcs->valid(intern->inner.iterator) == SUCCESS);
} /* }}} */
@@ -3147,7 +3123,7 @@ SPL_METHOD(NoRewindIterator, key)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (intern->inner.iterator->funcs->get_current_key) {
intern->inner.iterator->funcs->get_current_key(intern->inner.iterator, return_value);
@@ -3167,7 +3143,7 @@ SPL_METHOD(NoRewindIterator, current)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
data = intern->inner.iterator->funcs->get_current_data(intern->inner.iterator);
if (data) {
ZVAL_COPY_DEREF(return_value, data);
@@ -3184,7 +3160,7 @@ SPL_METHOD(NoRewindIterator, next)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
intern->inner.iterator->funcs->move_forward(intern->inner.iterator);
} /* }}} */
@@ -3220,7 +3196,7 @@ SPL_METHOD(InfiniteIterator, next)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
spl_dual_it_next(intern, 1);
if (spl_dual_it_valid(intern) == SUCCESS) {
@@ -3356,7 +3332,7 @@ SPL_METHOD(AppendIterator, append)
spl_dual_it_object *intern;
zval *it;
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
if (zend_parse_parameters_ex(ZEND_PARSE_PARAMS_QUIET, ZEND_NUM_ARGS(), "O", &it, zend_ce_iterator) == FAILURE) {
return;
@@ -3389,7 +3365,7 @@ SPL_METHOD(AppendIterator, current)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
spl_dual_it_fetch(intern, 1);
if (Z_TYPE(intern->current.data) != IS_UNDEF) {
@@ -3411,7 +3387,7 @@ SPL_METHOD(AppendIterator, rewind)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
intern->u.append.iterator->funcs->rewind(intern->u.append.iterator);
if (spl_append_it_next_iterator(intern) == SUCCESS) {
@@ -3429,7 +3405,7 @@ SPL_METHOD(AppendIterator, valid)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
RETURN_BOOL(Z_TYPE(intern->current.data) != IS_UNDEF);
} /* }}} */
@@ -3444,7 +3420,7 @@ SPL_METHOD(AppendIterator, next)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
spl_append_it_next(intern);
} /* }}} */
@@ -3459,7 +3435,7 @@ SPL_METHOD(AppendIterator, getIteratorIndex)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
APPENDIT_CHECK_CTOR(intern);
spl_array_iterator_key(&intern->u.append.zarrayit, return_value);
@@ -3476,7 +3452,7 @@ SPL_METHOD(AppendIterator, getArrayIterator)
return;
}
- SPL_FETCH_AND_CHECK_DUAL_IT(intern, getThis());
+ SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS);
value = &intern->u.append.zarrayit;
ZVAL_COPY_DEREF(return_value, value);
@@ -3597,11 +3573,7 @@ PHP_FUNCTION(iterator_to_array)
}
array_init(return_value);
-
- if (spl_iterator_apply(obj, use_keys ? spl_iterator_to_array_apply : spl_iterator_to_values_apply, (void*)return_value) != SUCCESS) {
- zval_ptr_dtor(return_value);
- RETURN_NULL();
- }
+ spl_iterator_apply(obj, use_keys ? spl_iterator_to_array_apply : spl_iterator_to_values_apply, (void*)return_value);
} /* }}} */
static int spl_iterator_count_apply(zend_object_iterator *iter, void *puser) /* {{{ */
@@ -3622,9 +3594,11 @@ PHP_FUNCTION(iterator_count)
RETURN_FALSE;
}
- if (spl_iterator_apply(obj, spl_iterator_count_apply, (void*)&count) == SUCCESS) {
- RETURN_LONG(count);
+ if (spl_iterator_apply(obj, spl_iterator_count_apply, (void*)&count) == FAILURE) {
+ return;
}
+
+ RETURN_LONG(count);
}
/* }}} */
@@ -3663,12 +3637,13 @@ PHP_FUNCTION(iterator_apply)
apply_info.count = 0;
zend_fcall_info_args(&apply_info.fci, apply_info.args);
- if (spl_iterator_apply(apply_info.obj, spl_iterator_func_apply, (void*)&apply_info) == SUCCESS) {
- RETVAL_LONG(apply_info.count);
- } else {
- RETVAL_FALSE;
+ if (spl_iterator_apply(apply_info.obj, spl_iterator_func_apply, (void*)&apply_info) == FAILURE) {
+ zend_fcall_info_args(&apply_info.fci, NULL);
+ return;
}
+
zend_fcall_info_args(&apply_info.fci, NULL);
+ RETURN_LONG(apply_info.count);
}
/* }}} */
@@ -3756,7 +3731,6 @@ PHP_MINIT_FUNCTION(spl_iterators)
REGISTER_SPL_IMPLEMENTS(RecursiveIteratorIterator, OuterIterator);
REGISTER_SPL_SUB_CLASS_EX(InfiniteIterator, IteratorIterator, spl_dual_it_new, spl_funcs_InfiniteIterator);
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
REGISTER_SPL_SUB_CLASS_EX(RegexIterator, FilterIterator, spl_dual_it_new, spl_funcs_RegexIterator);
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "USE_KEY", REGIT_USE_KEY);
REGISTER_SPL_CLASS_CONST_LONG(RegexIterator, "INVERT_MATCH",REGIT_INVERTED);
@@ -3768,10 +3742,6 @@ PHP_MINIT_FUNCTION(spl_iterators)
REGISTER_SPL_PROPERTY(RegexIterator, "replacement", 0);
REGISTER_SPL_SUB_CLASS_EX(RecursiveRegexIterator, RegexIterator, spl_dual_it_new, spl_funcs_RecursiveRegexIterator);
REGISTER_SPL_IMPLEMENTS(RecursiveRegexIterator, RecursiveIterator);
-#else
- spl_ce_RegexIterator = NULL;
- spl_ce_RecursiveRegexIterator = NULL;
-#endif
REGISTER_SPL_STD_CLASS_EX(EmptyIterator, NULL, spl_funcs_EmptyIterator);
REGISTER_SPL_ITERATOR(EmptyIterator);
@@ -3789,12 +3759,3 @@ PHP_MINIT_FUNCTION(spl_iterators)
return SUCCESS;
}
/* }}} */
-
-/*
- * 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_iterators.h b/ext/spl/spl_iterators.h
index cbb0744071..af2f815538 100644
--- a/ext/spl/spl_iterators.h
+++ b/ext/spl/spl_iterators.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -21,9 +21,7 @@
#include "php.h"
#include "php_spl.h"
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
#include "ext/pcre/php_pcre.h"
-#endif
#define spl_ce_Traversable zend_ce_traversable
#define spl_ce_Iterator zend_ce_iterator
@@ -71,10 +69,8 @@ typedef enum {
DIT_NoRewindIterator,
DIT_InfiniteIterator,
DIT_AppendIterator,
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
DIT_RegexIterator,
DIT_RecursiveRegexIterator,
-#endif
DIT_CallbackFilterIterator,
DIT_RecursiveCallbackFilterIterator,
DIT_Unknown = ~0
@@ -150,7 +146,6 @@ typedef struct _spl_dual_it_object {
zval zarrayit;
zend_object_iterator *iterator;
} append;
-#if HAVE_PCRE || HAVE_BUNDLED_PCRE
struct {
zend_long flags;
zend_long preg_flags;
@@ -159,7 +154,6 @@ typedef struct _spl_dual_it_object {
regex_mode mode;
int use_flags;
} regex;
-#endif
_spl_cbfilter_it_intern *cbfilter;
} u;
zend_object std;
@@ -176,12 +170,3 @@ typedef int (*spl_iterator_apply_func_t)(zend_object_iterator *iter, void *puser
PHPAPI int spl_iterator_apply(zval *obj, spl_iterator_apply_func_t apply_func, void *puser);
#endif /* SPL_ITERATORS_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/spl_observer.c b/ext/spl/spl_observer.c
index 212a53c206..5b1e2cfe7e 100644
--- a/ext/spl/spl_observer.c
+++ b/ext/spl/spl_observer.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -44,7 +44,7 @@ SPL_METHOD(SplSubject, detach);
SPL_METHOD(SplSubject, notify);
ZEND_BEGIN_ARG_INFO(arginfo_SplObserver_update, 0)
- ZEND_ARG_OBJ_INFO(0, SplSubject, SplSubject, 0)
+ ZEND_ARG_OBJ_INFO(0, subject, SplSubject, 0)
ZEND_END_ARG_INFO();
static const zend_function_entry spl_funcs_SplObserver[] = {
@@ -53,7 +53,7 @@ static const zend_function_entry spl_funcs_SplObserver[] = {
};
ZEND_BEGIN_ARG_INFO(arginfo_SplSubject_attach, 0)
- ZEND_ARG_OBJ_INFO(0, SplObserver, SplObserver, 0)
+ ZEND_ARG_OBJ_INFO(0, observer, SplObserver, 0)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO(arginfo_SplSubject_void, 0)
@@ -318,7 +318,7 @@ static HashTable* spl_object_storage_debug_info(zval *obj, int *is_temp) /* {{{
}
/* }}} */
-/* overriden for garbage collection */
+/* overridden for garbage collection */
static HashTable *spl_object_storage_get_gc(zval *obj, zval **table, int *n) /* {{{ */
{
int i = 0;
@@ -352,7 +352,7 @@ static int spl_object_storage_compare_info(zval *e1, zval *e2) /* {{{ */
return 1;
}
- return Z_LVAL(result) > 0 ? 1 : (Z_LVAL(result) < 0 ? -1 : 0);
+ return ZEND_NORMALIZE_BOOL(Z_LVAL(result));
}
/* }}} */
@@ -393,18 +393,18 @@ int spl_object_storage_contains(spl_SplObjectStorage *intern, zval *this, zval *
return found;
} /* }}} */
-/* {{{ proto void SplObjectStorage::attach(object obj, mixed inf = NULL)
+/* {{{ proto void SplObjectStorage::attach(object obj, mixed data = NULL)
Attaches an object to the storage if not yet contained */
SPL_METHOD(SplObjectStorage, attach)
{
zval *obj, *inf = NULL;
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o|z!", &obj, &inf) == FAILURE) {
return;
}
- spl_object_storage_attach(intern, getThis(), obj, inf);
+ spl_object_storage_attach(intern, ZEND_THIS, obj, inf);
} /* }}} */
/* {{{ proto void SplObjectStorage::detach(object obj)
@@ -412,12 +412,12 @@ SPL_METHOD(SplObjectStorage, attach)
SPL_METHOD(SplObjectStorage, detach)
{
zval *obj;
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
return;
}
- spl_object_storage_detach(intern, getThis(), obj);
+ spl_object_storage_detach(intern, ZEND_THIS, obj);
zend_hash_internal_pointer_reset_ex(&intern->storage, &intern->pos);
intern->index = 0;
@@ -443,14 +443,14 @@ SPL_METHOD(SplObjectStorage, offsetGet)
{
zval *obj;
spl_SplObjectStorageElement *element;
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
zend_hash_key key;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
return;
}
- if (spl_object_storage_get_hash(&key, intern, getThis(), obj) == FAILURE) {
+ if (spl_object_storage_get_hash(&key, intern, ZEND_THIS, obj) == FAILURE) {
return;
}
@@ -471,7 +471,7 @@ SPL_METHOD(SplObjectStorage, offsetGet)
SPL_METHOD(SplObjectStorage, addAll)
{
zval *obj;
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
spl_SplObjectStorage *other;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "O", &obj, spl_ce_SplObjectStorage) == FAILURE) {
@@ -480,7 +480,7 @@ SPL_METHOD(SplObjectStorage, addAll)
other = Z_SPLOBJSTORAGE_P(obj);
- spl_object_storage_addall(intern, getThis(), other);
+ spl_object_storage_addall(intern, ZEND_THIS, other);
RETURN_LONG(zend_hash_num_elements(&intern->storage));
} /* }}} */
@@ -490,7 +490,7 @@ SPL_METHOD(SplObjectStorage, addAll)
SPL_METHOD(SplObjectStorage, removeAll)
{
zval *obj;
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
spl_SplObjectStorage *other;
spl_SplObjectStorageElement *element;
@@ -502,7 +502,7 @@ SPL_METHOD(SplObjectStorage, removeAll)
zend_hash_internal_pointer_reset(&other->storage);
while ((element = zend_hash_get_current_data_ptr(&other->storage)) != NULL) {
- if (spl_object_storage_detach(intern, getThis(), &element->obj) == FAILURE) {
+ if (spl_object_storage_detach(intern, ZEND_THIS, &element->obj) == FAILURE) {
zend_hash_move_forward(&other->storage);
}
}
@@ -518,7 +518,7 @@ SPL_METHOD(SplObjectStorage, removeAll)
SPL_METHOD(SplObjectStorage, removeAllExcept)
{
zval *obj;
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
spl_SplObjectStorage *other;
spl_SplObjectStorageElement *element;
@@ -529,8 +529,8 @@ SPL_METHOD(SplObjectStorage, removeAllExcept)
other = Z_SPLOBJSTORAGE_P(obj);
ZEND_HASH_FOREACH_PTR(&intern->storage, element) {
- if (!spl_object_storage_contains(other, getThis(), &element->obj)) {
- spl_object_storage_detach(intern, getThis(), &element->obj);
+ if (!spl_object_storage_contains(other, ZEND_THIS, &element->obj)) {
+ spl_object_storage_detach(intern, ZEND_THIS, &element->obj);
}
} ZEND_HASH_FOREACH_END();
@@ -546,19 +546,19 @@ SPL_METHOD(SplObjectStorage, removeAllExcept)
SPL_METHOD(SplObjectStorage, contains)
{
zval *obj;
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "o", &obj) == FAILURE) {
return;
}
- RETURN_BOOL(spl_object_storage_contains(intern, getThis(), obj));
+ RETURN_BOOL(spl_object_storage_contains(intern, ZEND_THIS, obj));
} /* }}} */
/* {{{ proto int SplObjectStorage::count()
Determine number of objects in storage */
SPL_METHOD(SplObjectStorage, count)
{
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
zend_long mode = COUNT_NORMAL;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "|l", &mode) == FAILURE) {
@@ -585,7 +585,7 @@ SPL_METHOD(SplObjectStorage, count)
Rewind to first position */
SPL_METHOD(SplObjectStorage, rewind)
{
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -599,7 +599,7 @@ SPL_METHOD(SplObjectStorage, rewind)
Returns whether current position is valid */
SPL_METHOD(SplObjectStorage, valid)
{
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -612,7 +612,7 @@ SPL_METHOD(SplObjectStorage, valid)
Returns current key */
SPL_METHOD(SplObjectStorage, key)
{
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -626,7 +626,7 @@ SPL_METHOD(SplObjectStorage, key)
SPL_METHOD(SplObjectStorage, current)
{
spl_SplObjectStorageElement *element;
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -643,7 +643,7 @@ SPL_METHOD(SplObjectStorage, current)
SPL_METHOD(SplObjectStorage, getInfo)
{
spl_SplObjectStorageElement *element;
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -660,7 +660,7 @@ SPL_METHOD(SplObjectStorage, getInfo)
SPL_METHOD(SplObjectStorage, setInfo)
{
spl_SplObjectStorageElement *element;
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
zval *inf;
if (zend_parse_parameters(ZEND_NUM_ARGS(), "z", &inf) == FAILURE) {
@@ -678,7 +678,7 @@ SPL_METHOD(SplObjectStorage, setInfo)
Moves position forward */
SPL_METHOD(SplObjectStorage, next)
{
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -692,7 +692,7 @@ SPL_METHOD(SplObjectStorage, next)
Serializes storage */
SPL_METHOD(SplObjectStorage, serialize)
{
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
spl_SplObjectStorageElement *element;
zval members, flags;
@@ -729,7 +729,7 @@ SPL_METHOD(SplObjectStorage, serialize)
/* members */
smart_str_appendl(&buf, "m:", 2);
- ZVAL_ARR(&members, zend_array_dup(zend_std_get_properties(getThis())));
+ ZVAL_ARR(&members, zend_array_dup(zend_std_get_properties(ZEND_THIS)));
php_var_serialize(&buf, &members, &var_hash); /* finishes the string */
zval_ptr_dtor(&members);
@@ -748,7 +748,7 @@ SPL_METHOD(SplObjectStorage, serialize)
Unserializes storage */
SPL_METHOD(SplObjectStorage, unserialize)
{
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
char *buf;
size_t buf_len;
@@ -817,7 +817,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
goto outexcept;
}
- if (spl_object_storage_get_hash(&key, intern, getThis(), &entry) == FAILURE) {
+ if (spl_object_storage_get_hash(&key, intern, ZEND_THIS, &entry) == FAILURE) {
zval_ptr_dtor(&entry);
zval_ptr_dtor(&inf);
goto outexcept;
@@ -832,7 +832,7 @@ SPL_METHOD(SplObjectStorage, unserialize)
var_push_dtor(&var_hash, &pelement->obj);
}
}
- element = spl_object_storage_attach(intern, getThis(), &entry, Z_ISUNDEF(inf)?NULL:&inf);
+ element = spl_object_storage_attach(intern, ZEND_THIS, &entry, Z_ISUNDEF(inf)?NULL:&inf);
var_replace(&var_hash, &entry, &element->obj);
var_replace(&var_hash, &inf, &element->inf);
zval_ptr_dtor(&entry);
@@ -870,13 +870,85 @@ outexcept:
} /* }}} */
+/* {{{ proto auto SplObjectStorage::__serialize() */
+SPL_METHOD(SplObjectStorage, __serialize)
+{
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
+ spl_SplObjectStorageElement *elem;
+ zval tmp;
+
+ if (zend_parse_parameters_none_throw() == FAILURE) {
+ return;
+ }
+
+ array_init(return_value);
+
+ /* storage */
+ array_init_size(&tmp, 2 * zend_hash_num_elements(&intern->storage));
+ ZEND_HASH_FOREACH_PTR(&intern->storage, elem) {
+ Z_TRY_ADDREF(elem->obj);
+ zend_hash_next_index_insert(Z_ARRVAL(tmp), &elem->obj);
+ Z_TRY_ADDREF(elem->inf);
+ zend_hash_next_index_insert(Z_ARRVAL(tmp), &elem->inf);
+ } ZEND_HASH_FOREACH_END();
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
+
+ /* members */
+ ZVAL_ARR(&tmp, zend_std_get_properties(ZEND_THIS));
+ Z_TRY_ADDREF(tmp);
+ zend_hash_next_index_insert(Z_ARRVAL_P(return_value), &tmp);
+} /* }}} */
+
+/* {{{ proto void SplObjectStorage::__unserialize(array serialized) */
+SPL_METHOD(SplObjectStorage, __unserialize)
+{
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
+ HashTable *data;
+ zval *storage_zv, *members_zv, *key, *val;
+
+ if (zend_parse_parameters_throw(ZEND_NUM_ARGS(), "h", &data) == FAILURE) {
+ return;
+ }
+
+ storage_zv = zend_hash_index_find(data, 0);
+ members_zv = zend_hash_index_find(data, 1);
+ if (!storage_zv || !members_zv ||
+ Z_TYPE_P(storage_zv) != IS_ARRAY || Z_TYPE_P(members_zv) != IS_ARRAY) {
+ zend_throw_exception(spl_ce_UnexpectedValueException,
+ "Incomplete or ill-typed serialization data", 0);
+ return;
+ }
+
+ if (zend_hash_num_elements(Z_ARRVAL_P(storage_zv)) % 2 != 0) {
+ zend_throw_exception(spl_ce_UnexpectedValueException, "Odd number of elements", 0);
+ return;
+ }
+
+ key = NULL;
+ ZEND_HASH_FOREACH_VAL(Z_ARRVAL_P(storage_zv), val) {
+ if (key) {
+ if (Z_TYPE_P(key) != IS_OBJECT) {
+ zend_throw_exception(spl_ce_UnexpectedValueException, "Non-object key", 0);
+ return;
+ }
+
+ spl_object_storage_attach(intern, ZEND_THIS, key, val);
+ key = NULL;
+ } else {
+ key = val;
+ }
+ } ZEND_HASH_FOREACH_END();
+
+ object_properties_load(&intern->std, Z_ARRVAL_P(members_zv));
+}
+
ZEND_BEGIN_ARG_INFO(arginfo_Object, 0)
ZEND_ARG_INFO(0, object)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO_EX(arginfo_attach, 0, 0, 1)
ZEND_ARG_INFO(0, object)
- ZEND_ARG_INFO(0, inf)
+ ZEND_ARG_INFO(0, data)
ZEND_END_ARG_INFO();
ZEND_BEGIN_ARG_INFO(arginfo_Serialized, 0)
@@ -919,6 +991,8 @@ static const zend_function_entry spl_funcs_SplObjectStorage[] = {
/* Serializable */
SPL_ME(SplObjectStorage, unserialize, arginfo_Serialized, 0)
SPL_ME(SplObjectStorage, serialize, arginfo_splobject_void,0)
+ SPL_ME(SplObjectStorage, __unserialize, arginfo_Serialized, 0)
+ SPL_ME(SplObjectStorage, __serialize, arginfo_splobject_void,0)
/* ArrayAccess */
SPL_MA(SplObjectStorage, offsetExists, SplObjectStorage, contains, arginfo_offsetGet, 0)
SPL_MA(SplObjectStorage, offsetSet, SplObjectStorage, attach, arginfo_attach, 0)
@@ -948,7 +1022,7 @@ SPL_METHOD(MultipleIterator, __construct)
return;
}
- intern = Z_SPLOBJSTORAGE_P(getThis());
+ intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
intern->flags = flags;
}
/* }}} */
@@ -957,7 +1031,7 @@ SPL_METHOD(MultipleIterator, __construct)
Return current flags */
SPL_METHOD(MultipleIterator, getFlags)
{
- spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(getThis());
+ spl_SplObjectStorage *intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -971,7 +1045,7 @@ SPL_METHOD(MultipleIterator, getFlags)
SPL_METHOD(MultipleIterator, setFlags)
{
spl_SplObjectStorage *intern;
- intern = Z_SPLOBJSTORAGE_P(getThis());
+ intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters(ZEND_NUM_ARGS(), "l", &intern->flags) == FAILURE) {
return;
@@ -990,7 +1064,7 @@ SPL_METHOD(MultipleIterator, attachIterator)
return;
}
- intern = Z_SPLOBJSTORAGE_P(getThis());
+ intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (info != NULL) {
spl_SplObjectStorageElement *element;
@@ -1010,7 +1084,7 @@ SPL_METHOD(MultipleIterator, attachIterator)
}
}
- spl_object_storage_attach(intern, getThis(), iterator, info);
+ spl_object_storage_attach(intern, ZEND_THIS, iterator, info);
}
/* }}} */
@@ -1022,7 +1096,7 @@ SPL_METHOD(MultipleIterator, rewind)
spl_SplObjectStorageElement *element;
zval *it;
- intern = Z_SPLOBJSTORAGE_P(getThis());
+ intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1045,7 +1119,7 @@ SPL_METHOD(MultipleIterator, next)
spl_SplObjectStorageElement *element;
zval *it;
- intern = Z_SPLOBJSTORAGE_P(getThis());
+ intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1069,7 +1143,7 @@ SPL_METHOD(MultipleIterator, valid)
zval *it, retval;
zend_long expect, valid;
- intern = Z_SPLOBJSTORAGE_P(getThis());
+ intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1177,7 +1251,7 @@ static void spl_multiple_iterator_get_all(spl_SplObjectStorage *intern, int get_
SPL_METHOD(MultipleIterator, current)
{
spl_SplObjectStorage *intern;
- intern = Z_SPLOBJSTORAGE_P(getThis());
+ intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1192,7 +1266,7 @@ SPL_METHOD(MultipleIterator, current)
SPL_METHOD(MultipleIterator, key)
{
spl_SplObjectStorage *intern;
- intern = Z_SPLOBJSTORAGE_P(getThis());
+ intern = Z_SPLOBJSTORAGE_P(ZEND_THIS);
if (zend_parse_parameters_none() == FAILURE) {
return;
@@ -1269,12 +1343,3 @@ PHP_MINIT_FUNCTION(spl_observer)
return SUCCESS;
}
/* }}} */
-
-/*
- * 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_observer.h b/ext/spl/spl_observer.h
index 3ca9692954..50d65f63ab 100644
--- a/ext/spl/spl_observer.h
+++ b/ext/spl/spl_observer.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 7 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2018 The PHP Group |
+ | Copyright (c) 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 |
@@ -30,12 +30,3 @@ extern PHPAPI zend_class_entry *spl_ce_MultipleIterator;
PHP_MINIT_FUNCTION(spl_observer);
#endif /* SPL_OBSERVER_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/ArrayObject_get_object_vars.phpt b/ext/spl/tests/ArrayObject_get_object_vars.phpt
new file mode 100644
index 0000000000..a80add6b95
--- /dev/null
+++ b/ext/spl/tests/ArrayObject_get_object_vars.phpt
@@ -0,0 +1,30 @@
+--TEST--
+get_object_vars() on ArrayObject works on the properties of the ArrayObject itself
+--FILE--
+<?php
+
+class Test {
+ public $test;
+ public $test2;
+}
+
+class AO extends ArrayObject {
+ private $test;
+
+ public function getObjectVars() {
+ return get_object_vars($this);
+ }
+}
+
+$ao = new AO(new Test);
+var_dump(get_object_vars($ao));
+var_dump($ao->getObjectVars());
+
+?>
+--EXPECT--
+array(0) {
+}
+array(1) {
+ ["test"]=>
+ NULL
+}
diff --git a/ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt b/ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt
deleted file mode 100644
index ce754d398d..0000000000
--- a/ext/spl/tests/DirectoryIterator_getBasename_pass_array.phpt
+++ /dev/null
@@ -1,23 +0,0 @@
---TEST--
-DirectoryIterator::getBasename() - Pass unexpected array
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
- $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename2');
- mkdir($targetDir);
- touch($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt');
- $dir = new DirectoryIterator($targetDir.DIRECTORY_SEPARATOR);
- while(!$dir->isFile()) {
- $dir->next();
- }
- echo $dir->getBasename(array());
-?>
---CLEAN--
-<?php
- $targetDir = __DIR__.DIRECTORY_SEPARATOR.md5('directoryIterator::getbasename2');
- unlink($targetDir.DIRECTORY_SEPARATOR.'getBasename_test.txt');
- rmdir($targetDir);
-?>
---EXPECTF--
-Warning: DirectoryIterator::getBasename() expects parameter 1 to be string, array given in %s on line %d
diff --git a/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt b/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
index 176b73d803..157449c5cd 100644
--- a/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getExtension_basic.phpt
@@ -1,29 +1,26 @@
--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;
-mkdir($dir);
-$files = array('test.txt', 'test.extension', 'test..', 'test.', 'test');
+if (!mkdir($dir)) {
+ die('Failed to create test directory');
+}
+
+$files = array('test.txt', 'test.extension', 'test');
foreach ($files as $file) {
touch($dir . $file);
}
$dit_exts = array();
$nfo_exts = array();
-$skip = array('.', '..');
foreach (new DirectoryIterator($dir) as $file) {
- if (in_array($file->getFilename(), $skip)) {
+ if ($file->isDot()) {
continue;
}
+
$dit_exts[] = $file->getExtension();
$nfo_exts[] = pathinfo($file->getFilename(), PATHINFO_EXTENSION);
}
@@ -34,7 +31,7 @@ var_dump($dit_exts);
--CLEAN--
<?php
$dir = __DIR__ . DIRECTORY_SEPARATOR . md5('DirectoryIterator::getExtension') . DIRECTORY_SEPARATOR;
-$files = array('test.txt', 'test.extension', 'test..', 'test.', 'test');
+$files = array('test.txt', 'test.extension', 'test');
foreach ($files as $file) {
unlink($dir . $file);
}
@@ -42,15 +39,11 @@ rmdir($dir);
?>
--EXPECT--
bool(true)
-array(5) {
+array(3) {
[0]=>
string(0) ""
[1]=>
- string(0) ""
- [2]=>
- string(0) ""
- [3]=>
string(9) "extension"
- [4]=>
+ [2]=>
string(3) "txt"
}
diff --git a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
index 81ab6c0921..74586b7e0f 100644
--- a/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getGroup_basic.phpt
@@ -2,7 +2,8 @@
SPL: DirectoryIterator test getGroup
--SKIPIF--
<?php
-if (posix_geteuid() == 0) die('SKIP Cannot run test as root.');
+if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file groups, not available for Windows'); }
+if (!extension_loaded('posix') || 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/DirectoryIterator_getInode_basic.phpt b/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
index a6b128a222..95d20881bc 100644
--- a/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getInode_basic.phpt
@@ -10,7 +10,7 @@ Jacopo Romei <jacopo@sviluppoagile.it>
#Test Fest Cesena (Italy) on 2009-06-20
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file inodes, not available for Windows'); }
?>
--FILE--
<?php
diff --git a/ext/spl/tests/DirectoryIterator_getInode_error.phpt b/ext/spl/tests/DirectoryIterator_getInode_error.phpt
index fd89ecd1ca..42bfa35847 100644
--- a/ext/spl/tests/DirectoryIterator_getInode_error.phpt
+++ b/ext/spl/tests/DirectoryIterator_getInode_error.phpt
@@ -10,7 +10,7 @@ Jacopo Romei <jacopo@sviluppoagile.it>
#Test Fest Cesena (Italy) on 2009-06-20
--SKIPIF--
<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
+if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file inodes, not available for Windows'); }
?>
--FILE--
<?php
diff --git a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
index 709510d7cf..0981a7d286 100644
--- a/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
+++ b/ext/spl/tests/DirectoryIterator_getOwner_basic.phpt
@@ -2,7 +2,8 @@
SPL: DirectoryIterator test getOwner
--SKIPIF--
<?php
-if (posix_geteuid() == 0) die('SKIP Cannot run test as root.');
+if (PHP_OS_FAMILY === 'Windows') { die('SKIP Testing file ownership, not available for Windows'); }
+if (!extension_loaded('posix') || 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/SPLDoublyLinkedList_iterate_by_reference.phpt b/ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt
new file mode 100644
index 0000000000..8c3aad3ef7
--- /dev/null
+++ b/ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt
@@ -0,0 +1,26 @@
+--TEST--
+SplDoublyLinkedList Iterating a DLL by reference shouldn't be permitted
+--CREDITS--
+Mark Baker mark@lange.demon.co.uk at the PHPNW2017 Conference for PHP Testfest 2017
+--FILE--
+<?php
+
+$dll = new SplDoublyLinkedList();
+
+$dll->push(2);
+$dll->push(3);
+
+try {
+ foreach($dll as $key => &$value) {
+ // We should never see this output, because the "by reference" exception should be thrown in the previous line
+ echo $value, PHP_EOL;
+ $value *= $value;
+ echo $value, PHP_EOL;
+ }
+} catch (Exception $e) {
+ echo $e->getMessage(), PHP_EOL;
+}
+
+?>
+--EXPECT--
+An iterator cannot be used with foreach by reference
diff --git a/ext/spl/tests/SplDoublyLinkedList_add_missing_parameter1.phpt b/ext/spl/tests/SplDoublyLinkedList_add_missing_parameter1.phpt
deleted file mode 100644
index 4af0d0b704..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_add_missing_parameter1.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-Check that SplDoublyLinkedList::add generate a warning and returns a NULL with missing arguments
---FILE--
-<?php
-$dll = new SplDoublyLinkedList();
-var_dump($dll->add());
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::add() expects exactly 2 parameters, 0 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplDoublyLinkedList_add_missing_parameter2.phpt b/ext/spl/tests/SplDoublyLinkedList_add_missing_parameter2.phpt
deleted file mode 100644
index ac87bf1979..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_add_missing_parameter2.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-Check that SplDoublyLinkedList::add generate a warning and returns a NULL with a missing value argument
---FILE--
-<?php
-$dll = new SplDoublyLinkedList();
-var_dump($dll->add(2));
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::add() expects exactly 2 parameters, 1 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_array.phpt b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_array.phpt
deleted file mode 100644
index 36b186d6b7..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_array.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SplDoublyLinkedList::bottom() - pass in an unexpected array parameter
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
-
-$list = new SplDoublyLinkedList();
-$list->push("top");
-$list->bottom(array());
-
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_float.phpt b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_float.phpt
deleted file mode 100644
index 94312a0f60..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_float.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SplDoublyLinkedList::bottom() - pass in an unexpected float parameter
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
-
-$list = new SplDoublyLinkedList();
-$list->push("top");
-$list->bottom(3.14159);
-
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_integer.phpt b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_integer.phpt
deleted file mode 100644
index 651f1e4382..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_integer.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SplDoublyLinkedList::bottom() - pass in an unexpected integer parameter
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
-
-$list = new SplDoublyLinkedList();
-$list->push("top");
-$list->bottom(45);
-
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_null.phpt b/ext/spl/tests/SplDoublyLinkedList_bottom_pass_null.phpt
deleted file mode 100644
index efc6b8ae50..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_bottom_pass_null.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SplDoublyLinkedList::bottom() - pass in an unexpected null parameter
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
-
-$list = new SplDoublyLinkedList();
-$list->push("top");
-$list->bottom(null);
-
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::bottom() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_count.phpt b/ext/spl/tests/SplDoublyLinkedList_count.phpt
deleted file mode 100644
index 72b029cce4..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_count.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-Check that SplDoublyLinkedList::count fails if parameter passed in
---CREDITS--
-Rob Knight <themanhimself@robknight.org.uk> PHPNW Test Fest 2009
---FILE--
-<?php
-$list = new SplDoublyLinkedList();
-
-$c = $list->count('foo');
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::count() expects exactly 0 parameters, 1 given in %s on line 4
diff --git a/ext/spl/tests/SplDoublyLinkedList_count_param_SplDoublyLinkedList.phpt b/ext/spl/tests/SplDoublyLinkedList_count_param_SplDoublyLinkedList.phpt
deleted file mode 100644
index 463f1a104d..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_count_param_SplDoublyLinkedList.phpt
+++ /dev/null
@@ -1,11 +0,0 @@
---TEST--
-Create a SplDoublyLinkedList, call count() and pass a SplDoublyLinkedList object as the parameter.
---CREDITS--
-Philip Norton philipnorton42@gmail.com
---FILE--
-<?php
-$dll = new SplDoublyLinkedList(2);
-$dll->count(new SplDoublyLinkedList(2));
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::count() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_getIteratorMode_error.phpt b/ext/spl/tests/SplDoublyLinkedList_getIteratorMode_error.phpt
deleted file mode 100644
index b9810fc214..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_getIteratorMode_error.phpt
+++ /dev/null
@@ -1,11 +0,0 @@
---TEST--
-SplDoublyLinkedList getIteratorMode with an unexpected parameter
---CREDITS--
-PHPNW Testfest 2009 - Lorna Mitchell
---FILE--
-<?php
-$list = new SplDoublyLinkedList();
-$list->getIteratorMode(24);
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::getIteratorMode() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty-with-parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty-with-parameter.phpt
deleted file mode 100644
index 18456244bd..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_isEmpty_empty-with-parameter.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-Check that SplDoublyLinkedList->isEmpty() returns an error message when a parameter is passed.
---CREDITS--
-PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
---FILE--
-<?php
- // Create a new Doubly Linked List
- $dll = new SplDoublyLinkedList();
-
- var_dump($dll->isEmpty("test"));
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::isEmpty() expects exactly 0 parameters, %d given in %s
-NULL
diff --git a/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty-with-parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty-with-parameter.phpt
deleted file mode 100644
index c88a72a25c..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_isEmpty_not-empty-with-parameter.phpt
+++ /dev/null
@@ -1,20 +0,0 @@
---TEST--
-Check that SplDoublyLinkedList->isEmpty() returns an error message when a parameter is passed.
---CREDITS--
-PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
---FILE--
-<?php
- // Create a new Doubly Linked List
- $dll = new SplDoublyLinkedList();
-
- // Add some items to the list
- $dll->push(1);
- $dll->push(2);
- $dll->push(3);
- //var_dump($dll);
-
- var_dump($dll->isEmpty("test"));
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::isEmpty() expects exactly 0 parameters, %d given in %s
-NULL
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetExists_invalid_parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetExists_invalid_parameter.phpt
deleted file mode 100644
index f0e1b8ba14..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_offsetExists_invalid_parameter.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-SPL SplDoublyLinkedList offsetExists displays warning and returns null on no parameters
---CREDITS--
-PHPNW TestFest 2009 - Ben Longden
---FILE--
-<?php
-$list = new SplDoublyLinkedList();
-$a = $list->offsetExists();
-if(is_null($a)) {
- echo 'PASS';
-}
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::offsetExists() expects exactly 1 parameter, 0 given in %s on line %d
-PASS
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetGet_empty.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetGet_empty.phpt
deleted file mode 100644
index d776d69223..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_offsetGet_empty.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SplDoublyLinkedList::offsetGet() with no parameter passed.
---CREDITS--
-PHPNW Test Fest 2009 - Jordan Hatch
---FILE--
-<?php
-
-$array = new SplDoublyLinkedList( );
-
-$get = $array->offsetGet();
-
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::offsetGet() expects exactly 1 parameter, 0 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetGet_missing_param.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetGet_missing_param.phpt
deleted file mode 100644
index beffe7ad87..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_offsetGet_missing_param.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-Tests that the offsetGet() method throws an error when no argument is sent
---CREDITS--
-PHPNW Test Fest 2009 - Rick Ogden
---FILE--
-<?php
-$dll = new SplDoublyLinkedList();
-$dll->push(1);
-$dll->push(2);
-
-var_dump($dll->offsetGet());
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::offsetGet() expects exactly 1 parameter, 0 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetSet_invalid_parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetSet_invalid_parameter.phpt
deleted file mode 100644
index 2447e798a1..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_offsetSet_invalid_parameter.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-SplDoublyLinkedList offsetSet throws error on no parameters
---CREDITS--
-PHPNW TestFest 2009 - Ben Longden
---FILE--
-<?php
-$list = new SplDoublyLinkedList();
-$a = $list->offsetSet();
-if(is_null($a)) {
- echo 'PASS';
-}
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::offsetSet() expects exactly 2 parameters, 0 given in %s on line %d
-PASS
diff --git a/ext/spl/tests/SplDoublyLinkedList_offsetSet_one_invalid_parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_offsetSet_one_invalid_parameter.phpt
deleted file mode 100644
index 244dcd5b03..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_offsetSet_one_invalid_parameter.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-SplDoublyLinkedList offsetSet throws error only one parameter
---CREDITS--
-PHPNW TestFest 2009 - Ben Longden
---FILE--
-<?php
-$list = new SplDoublyLinkedList();
-$a = $list->offsetSet(2);
-if(is_null($a)) {
- echo 'PASS';
-}
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::offsetSet() expects exactly 2 parameters, 1 given in %s on line %d
-PASS
diff --git a/ext/spl/tests/SplDoublyLinkedList_pop_noParams.phpt b/ext/spl/tests/SplDoublyLinkedList_pop_noParams.phpt
deleted file mode 100644
index 64f3a48150..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_pop_noParams.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-Checks that the pop() method of DoublyLinkedList does not accept args.
---CREDITS--
-PHPNW Test Fest 2009 - Rick Ogden
---FILE--
-<?php
-$ll = new SplDoublyLinkedList();
-$ll->push(1);
-$ll->push(2);
-
-var_dump($ll->pop(1));
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::pop() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplDoublyLinkedList_pop_params.phpt b/ext/spl/tests/SplDoublyLinkedList_pop_params.phpt
deleted file mode 100644
index a3df71bc71..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_pop_params.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SplDoublyLinkedList::offsetGet() with no parameter passed.
---CREDITS--
-PHPNW Test Fest 2009 - Jordan Hatch
---FILE--
-<?php
-
-$array = new SplDoublyLinkedList( );
-
-$get = $array->pop( 'param' );
-
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::pop() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_push_missing_parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_push_missing_parameter.phpt
deleted file mode 100644
index 26fb3a9b8d..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_push_missing_parameter.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-Check that SplDoublyLinkedList::push generate a warning and return NULL with missing param
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-$dll = new SplDoublyLinkedList();
-var_dump($dll->push());
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::push() expects exactly 1 parameter, 0 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplDoublyLinkedList_serialization.phpt b/ext/spl/tests/SplDoublyLinkedList_serialization.phpt
index 7ab7d78174..d04e0cbe72 100644
--- a/ext/spl/tests/SplDoublyLinkedList_serialization.phpt
+++ b/ext/spl/tests/SplDoublyLinkedList_serialization.phpt
@@ -29,7 +29,7 @@ object(SplQueue)#%d (2) {
string(1) "b"
}
}
-string(42) "C:8:"SplQueue":22:{i:4;:s:1:"a";:s:1:"b";}"
+string(71) "O:8:"SplQueue":3:{i:0;i:4;i:1;a:2:{i:0;s:1:"a";i:1;s:1:"b";}i:2;a:0:{}}"
object(SplQueue)#%d (2) {
["flags":"SplDoublyLinkedList":private]=>
int(4)
@@ -52,7 +52,7 @@ object(SplStack)#%d (2) {
string(1) "b"
}
}
-string(42) "C:8:"SplStack":22:{i:6;:s:1:"a";:s:1:"b";}"
+string(71) "O:8:"SplStack":3:{i:0;i:6;i:1;a:2:{i:0;s:1:"a";i:1;s:1:"b";}i:2;a:0:{}}"
object(SplStack)#%d (2) {
["flags":"SplDoublyLinkedList":private]=>
int(6)
diff --git a/ext/spl/tests/SplDoublyLinkedList_setIteratorMode_param_SplDoublyLinkedList.phpt b/ext/spl/tests/SplDoublyLinkedList_setIteratorMode_param_SplDoublyLinkedList.phpt
deleted file mode 100644
index a990394334..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_setIteratorMode_param_SplDoublyLinkedList.phpt
+++ /dev/null
@@ -1,11 +0,0 @@
---TEST--
-Create a SplDoublyLinkedList, call setIteratorMode() and pass a SplDoublyLinkedList object as the parameter.
---CREDITS--
-Philip Norton philipnorton42@gmail.com
---FILE--
-<?php
-$dll = new SplDoublyLinkedList(2);
-$dll->setIteratorMode(new SplDoublyLinkedList(2));
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::setIteratorMode() expects parameter 1 to be int, object given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_top_pass_array.phpt b/ext/spl/tests/SplDoublyLinkedList_top_pass_array.phpt
deleted file mode 100644
index 2e2632d39a..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_top_pass_array.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SplDoublyLinkedList::top() - pass in an unexpected array
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
-
-$list = new SplDoublyLinkedList();
-$list->push("top");
-$list->top(array());
-
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::top() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_top_pass_float.phpt b/ext/spl/tests/SplDoublyLinkedList_top_pass_float.phpt
deleted file mode 100644
index 0a481b85a0..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_top_pass_float.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SplDoublyLinkedList::top() - pass in an unexpected float parameter
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
-
-$list = new SplDoublyLinkedList();
-$list->push("top");
-$list->top(3.14159);
-
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::top() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_top_pass_integer.phpt b/ext/spl/tests/SplDoublyLinkedList_top_pass_integer.phpt
deleted file mode 100644
index 72bdbabc3d..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_top_pass_integer.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SplDoublyLinkedList::top() - pass in an unexpected integer parameter
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
-
-$list = new SplDoublyLinkedList();
-$list->push("top");
-$list->top(45);
-
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::top() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_top_pass_null.phpt b/ext/spl/tests/SplDoublyLinkedList_top_pass_null.phpt
deleted file mode 100644
index 6a92399739..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_top_pass_null.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SplDoublyLinkedList::top() - pass in an unexpected null parameter
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
-
-$list = new SplDoublyLinkedList();
-$list->push("top");
-$list->top(null);
-
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::top() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplDoublyLinkedList_unshift_missing_parameter.phpt b/ext/spl/tests/SplDoublyLinkedList_unshift_missing_parameter.phpt
deleted file mode 100644
index adc631407c..0000000000
--- a/ext/spl/tests/SplDoublyLinkedList_unshift_missing_parameter.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-Check that SplDoublyLinkedList::unshift generate a warning and return NULL with missing param
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-$dll = new SplDoublyLinkedList();
-var_dump($dll->unshift());
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::unshift() expects exactly 1 parameter, 0 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt b/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
index 7d8aa7e621..51882c46ce 100644
--- a/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
+++ b/ext/spl/tests/SplDoublylinkedlist_offsetunset_first.phpt
@@ -11,7 +11,7 @@ $list->push('thar');
$list->offsetUnset(0);
var_dump($list);
?>
---EXPECTF--
+--EXPECT--
object(SplDoublyLinkedList)#1 (2) {
["flags":"SplDoublyLinkedList":private]=>
int(0)
diff --git a/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt b/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
index ac3cade344..f6dba97cfd 100644
--- a/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
+++ b/ext/spl/tests/SplDoublylinkedlist_offsetunset_last.phpt
@@ -11,7 +11,7 @@ $list->push('thar');
$list->offsetUnset(2);
var_dump($list);
?>
---EXPECTF--
+--EXPECT--
object(SplDoublyLinkedList)#1 (2) {
["flags":"SplDoublyLinkedList":private]=>
int(0)
diff --git a/ext/spl/tests/SplFileInfo_getGroup_error.phpt b/ext/spl/tests/SplFileInfo_getGroup_error.phpt
index 60dea49a10..b767849245 100644
--- a/ext/spl/tests/SplFileInfo_getGroup_error.phpt
+++ b/ext/spl/tests/SplFileInfo_getGroup_error.phpt
@@ -8,10 +8,6 @@ Daniel Londero <daniel.londero@gmail.com>
Francesco Trucchia <ft@ideato.it>
Jacopo Romei <jacopo@sviluppoagile.it>
#Test Fest Cesena (Italy) on 2009-06-20
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
-?>
--FILE--
<?php
diff --git a/ext/spl/tests/SplFileInfo_getInode_error.phpt b/ext/spl/tests/SplFileInfo_getInode_error.phpt
index 3bee5a982b..16c3f733e3 100644
--- a/ext/spl/tests/SplFileInfo_getInode_error.phpt
+++ b/ext/spl/tests/SplFileInfo_getInode_error.phpt
@@ -8,10 +8,6 @@ Daniel Londero <daniel.londero@gmail.com>
Francesco Trucchia <ft@ideato.it>
Jacopo Romei <jacopo@sviluppoagile.it>
#Test Fest Cesena (Italy) on 2009-06-20
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
-?>
--FILE--
<?php
diff --git a/ext/spl/tests/SplFileInfo_getOwner_error.phpt b/ext/spl/tests/SplFileInfo_getOwner_error.phpt
index d160b74298..17fc371dd9 100644
--- a/ext/spl/tests/SplFileInfo_getOwner_error.phpt
+++ b/ext/spl/tests/SplFileInfo_getOwner_error.phpt
@@ -8,10 +8,6 @@ Daniel Londero <daniel.londero@gmail.com>
Francesco Trucchia <ft@ideato.it>
Jacopo Romei <jacopo@sviluppoagile.it>
#Test Fest Cesena (Italy) on 2009-06-20
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
-?>
--FILE--
<?php
diff --git a/ext/spl/tests/SplFileInfo_getPerms_error.phpt b/ext/spl/tests/SplFileInfo_getPerms_error.phpt
index 632a053345..3b32726d0a 100644
--- a/ext/spl/tests/SplFileInfo_getPerms_error.phpt
+++ b/ext/spl/tests/SplFileInfo_getPerms_error.phpt
@@ -8,10 +8,6 @@ Daniel Londero <daniel.londero@gmail.com>
Francesco Trucchia <ft@ideato.it>
Jacopo Romei <jacopo@sviluppoagile.it>
#Test Fest Cesena (Italy) on 2009-06-20
---SKIPIF--
-<?php
-if (substr(PHP_OS, 0, 3) == 'WIN') die("skip this test not for Windows platforms");
-?>
--FILE--
<?php
diff --git a/ext/spl/tests/SplFileObject_current_error001.phpt b/ext/spl/tests/SplFileObject_current_error001.phpt
deleted file mode 100644
index 23c126648f..0000000000
--- a/ext/spl/tests/SplFileObject_current_error001.phpt
+++ /dev/null
@@ -1,19 +0,0 @@
---TEST--
-SPL: SplFileObject::current variation error
---CREDITS--
-Ricardo Oedietram <ricardo@odracir.nl>
-Erwin Poeze <erwin.poeze@gmail.com>
-#PFZ June PHP TestFest 2012
---FILE--
-<?php
-//line 2
-//line 3
-//line 4
-//line 5
-$s = new SplFileObject(__FILE__);
-$s->seek(2);
-
-echo $s->current('foo');
-?>
---EXPECTF--
-Warning: SplFileObject::current() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_fflush_basic_001.phpt b/ext/spl/tests/SplFileObject_fflush_basic_001.phpt
index bacdcb1daa..2060bd2b43 100644
--- a/ext/spl/tests/SplFileObject_fflush_basic_001.phpt
+++ b/ext/spl/tests/SplFileObject_fflush_basic_001.phpt
@@ -5,7 +5,7 @@ SplFileObject::fflush function - basic test
/*
* test a successful flush
*/
-$obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
+$obj = New SplFileObject(__DIR__.'/SplFileObject_testinput.csv');
var_dump($obj->fflush());
/*
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_empty.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_empty.phpt
new file mode 100644
index 0000000000..cbc539c323
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_empty.phpt
@@ -0,0 +1,31 @@
+--TEST--
+SplFileObject::fgetcsv() with empty $escape
+--FILE--
+<?php
+$contents = <<<EOS
+"cell1","cell2\\","cell3","cell4"
+"\\\\\\line1
+line2\\\\\\"
+EOS;
+$file = new SplTempFileObject;
+$file->fwrite($contents);
+$file->rewind();
+while (($data = $file->fgetcsv(',', '"', ''))) {
+ print_r($data);
+}
+?>
+===DONE===
+--EXPECT--
+Array
+(
+ [0] => cell1
+ [1] => cell2\
+ [2] => cell3
+ [3] => cell4
+)
+Array
+(
+ [0] => \\\line1
+line2\\\
+)
+===DONE===
diff --git a/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt b/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt
index b49bcdd13c..4873341e5a 100644
--- a/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt
+++ b/ext/spl/tests/SplFileObject_fgetcsv_escape_error.phpt
@@ -14,5 +14,5 @@ var_dump($fo->fgetcsv(',', '"', 'invalid'));
unlink('SplFileObject__fgetcsv8.csv');
?>
--EXPECTF--
-Warning: SplFileObject::fgetcsv(): escape must be a character in %s on line %d
+Warning: SplFileObject::fgetcsv(): escape must be empty or a single character in %s on line %d
bool(false)
diff --git a/ext/spl/tests/SplFileObject_fpassthru_basic.phpt b/ext/spl/tests/SplFileObject_fpassthru_basic.phpt
index 0bd349fc92..a79047830b 100644
--- a/ext/spl/tests/SplFileObject_fpassthru_basic.phpt
+++ b/ext/spl/tests/SplFileObject_fpassthru_basic.phpt
@@ -2,7 +2,7 @@
SplFileObject::fpassthru function - basic functionality test
--FILE--
<?php
-$obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
+$obj = New SplFileObject(__DIR__.'/SplFileObject_testinput.csv');
$obj->fpassthru();
?>
--EXPECT--
diff --git a/ext/spl/tests/SplFileObject_fputcsv_error.phpt b/ext/spl/tests/SplFileObject_fputcsv_error.phpt
deleted file mode 100644
index 4763455907..0000000000
--- a/ext/spl/tests/SplFileObject_fputcsv_error.phpt
+++ /dev/null
@@ -1,36 +0,0 @@
---TEST--
-SplFileObject::fputcsv(): error conditions
---FILE--
-<?php
-$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv2.csv', 'w');
-
-echo "*** Testing error conditions ***\n";
-// zero argument
-echo "-- Testing fputcsv() with zero argument --\n";
-var_dump( $fo->fputcsv() );
-
-// more than expected no. of args
-echo "-- Testing fputcsv() with more than expected number of arguments --\n";
-$fields = array("fld1", "fld2");
-$delim = ";";
-$enclosure ="\"";
-$escape = "\\";
-var_dump( $fo->fputcsv($fields, $delim, $enclosure, $escape, $fo) );
-
-echo "Done\n";
---CLEAN--
-<?php
-$file = __DIR__ . '/SplFileObject_fputcsv2.csv';
-unlink($file);
-?>
---EXPECTF--
-*** Testing error conditions ***
--- Testing fputcsv() with zero argument --
-
-Warning: SplFileObject::fputcsv() expects at least 1 parameter, 0 given in %s on line %d
-NULL
--- Testing fputcsv() with more than expected number of arguments --
-
-Warning: SplFileObject::fputcsv() expects at most 4 parameters, 5 given in %s on line %d
-NULL
-Done
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation1.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation1.phpt
index 879edefddf..47f8c609be 100644
--- a/ext/spl/tests/SplFileObject_fputcsv_variation1.phpt
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation1.phpt
@@ -23,7 +23,7 @@ $csv_lists = array (
array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
);
-$file_path = dirname(__FILE__);
+$file_path = __DIR__;
$file = "$file_path/fputcsv_variation1.tmp";
$file_modes = array ("r+", "r+b", "r+t",
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation10.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation10.phpt
index d23808b5ab..49f77d4158 100644
--- a/ext/spl/tests/SplFileObject_fputcsv_variation10.phpt
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation10.phpt
@@ -17,7 +17,7 @@ $fields = array( array('water_fruit\n'),
array("")
);
-$file_path = dirname(__FILE__);
+$file_path = __DIR__;
$file = "$file_path/fputcsv_variation10.tmp";
$file_modes = array ("r+", "r+b", "r+t",
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation11.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation11.phpt
index ab78d21b80..77d041689c 100644
--- a/ext/spl/tests/SplFileObject_fputcsv_variation11.phpt
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation11.phpt
@@ -23,7 +23,7 @@ $csv_lists = array (
array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
);
-$file_path = dirname(__FILE__);
+$file_path = __DIR__;
$file = "$file_path/fputcsv_variation11.tmp";
$file_modes = array ("r+", "r+b", "r+t",
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation12.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation12.phpt
index b530cf61cf..947d89b763 100644
--- a/ext/spl/tests/SplFileObject_fputcsv_variation12.phpt
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation12.phpt
@@ -24,7 +24,7 @@ $csv_lists = array (
array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
);
-$file_path = dirname(__FILE__);
+$file_path = __DIR__;
$file = "$file_path/fputcsv_variation12.tmp";
$file_modes = array ("r+", "r+b", "r+t",
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt
index 9edaf571fe..a4c2451021 100644
--- a/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation13.phpt
@@ -8,7 +8,7 @@ Test fputcsv() : usage variations - with default enclosure & delimiter of two ch
echo "*** Testing fputcsv() : with default enclosure & delimiter of two chars ***\n";
-$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w');
+$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv_variation13.csv', 'w');
var_dump($fo->fputcsv(array('water', 'fruit'), ',,', '"'));
@@ -18,7 +18,7 @@ echo "Done\n";
?>
--CLEAN--
<?php
-$file = __DIR__ . '/SplFileObject_fputcsv.csv';
+$file = __DIR__ . '/SplFileObject_fputcsv_variation13.csv';
unlink($file);
?>
--EXPECTF--
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt
index f8cda0e96f..a659da92af 100644
--- a/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation14.phpt
@@ -8,7 +8,7 @@ Test fputcsv() : usage variations - with enclosure & delimiter of two chars
echo "*** Testing fputcsv() : with enclosure & delimiter of two chars and file opened in read mode ***\n";
-$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv.csv', 'w');
+$fo = new SplFileObject(__DIR__ . '/SplFileObject_fputcsv_variation14.csv', 'w');
var_dump($fo->fputcsv(array('water', 'fruit'), ',,', '""'));
@@ -18,7 +18,7 @@ echo "Done\n";
?>
--CLEAN--
<?php
-$file = __DIR__ . '/SplFileObject_fputcsv.csv';
+$file = __DIR__ . '/SplFileObject_fputcsv_variation14.csv';
unlink($file);
?>
--EXPECTF--
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation15.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation15.phpt
new file mode 100644
index 0000000000..1cde292e28
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation15.phpt
@@ -0,0 +1,22 @@
+--TEST--
+SplFileObject::fputcsv() with empty $escape
+--FILE--
+<?php
+$data = array(
+ ['\\'],
+ ['\\"']
+);
+$file = new SplTempFileObject;
+foreach ($data as $record) {
+ $file->fputcsv($record, ',', '"', '');
+}
+$file->rewind();
+foreach ($file as $line) {
+ echo $line;
+}
+?>
+===DONE===
+--EXPECT--
+\
+"\"""
+===DONE===
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation5.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation5.phpt
index 002a7075a6..898d89681e 100644
--- a/ext/spl/tests/SplFileObject_fputcsv_variation5.phpt
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation5.phpt
@@ -23,7 +23,7 @@ $csv_lists = array (
array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
);
-$file_path = dirname(__FILE__);
+$file_path = __DIR__;
$file = "$file_path/fputcsv_variation5.tmp";
$file_modes = array ("r+", "r+b", "r+t",
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation6.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation6.phpt
index 1f177df19f..33bae5e48d 100644
--- a/ext/spl/tests/SplFileObject_fputcsv_variation6.phpt
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation6.phpt
@@ -26,7 +26,7 @@ $csv_lists = array (
array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
);
-$file_path = dirname(__FILE__);
+$file_path = __DIR__;
$file = "$file_path/fputcsv_variation6.tmp";
$file_modes = array ("r+", "r+b", "r+t",
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation7.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation7.phpt
index d42b455820..bae8962567 100644
--- a/ext/spl/tests/SplFileObject_fputcsv_variation7.phpt
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation7.phpt
@@ -26,7 +26,7 @@ $csv_lists = array (
array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
);
-$file_path = dirname(__FILE__);
+$file_path = __DIR__;
$file = "$file_path/fputcsv_variation7.tmp";
$file_modes = array ("r+", "r+b", "r+t",
diff --git a/ext/spl/tests/SplFileObject_fputcsv_variation8.phpt b/ext/spl/tests/SplFileObject_fputcsv_variation8.phpt
index f7cbd72b76..2306c92ce3 100644
--- a/ext/spl/tests/SplFileObject_fputcsv_variation8.phpt
+++ b/ext/spl/tests/SplFileObject_fputcsv_variation8.phpt
@@ -26,7 +26,7 @@ $csv_lists = array (
array(':', '&', array('&""""&:&"&:,:":&,&:,,,,'))
);
-$file_path = dirname(__FILE__);
+$file_path = __DIR__;
$file = "$file_path/fputcsv_variation8.tmp";
$file_modes = array ("r+", "r+b", "r+t",
diff --git a/ext/spl/tests/SplFileObject_fscanf_basic.phpt b/ext/spl/tests/SplFileObject_fscanf_basic.phpt
index 2f668ac73e..02de3f8d12 100644
--- a/ext/spl/tests/SplFileObject_fscanf_basic.phpt
+++ b/ext/spl/tests/SplFileObject_fscanf_basic.phpt
@@ -2,7 +2,7 @@
SplFileObject::fscanf function - basic functionality test
--FILE--
<?php
-$obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
+$obj = New SplFileObject(__DIR__.'/SplFileObject_testinput.csv');
var_dump($obj->fscanf('%s'));
?>
--EXPECT--
diff --git a/ext/spl/tests/SplFileObject_fseek_error_001.phpt b/ext/spl/tests/SplFileObject_fseek_error_001.phpt
deleted file mode 100644
index 0efeb98cb2..0000000000
--- a/ext/spl/tests/SplFileObject_fseek_error_001.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-SplFileObject::fseek function - parameters test
---FILE--
-<?php
-$obj = New SplFileObject(__FILE__);
-$obj->fseek(1,2,3);
-$obj->fseek();
-?>
---EXPECTF--
-Warning: SplFileObject::fseek() expects at most 2 parameters, 3 given %s
-
-Warning: SplFileObject::fseek() expects at least 1 parameter, 0 given %s
diff --git a/ext/spl/tests/SplFileObject_fwrite_error_001.phpt b/ext/spl/tests/SplFileObject_fwrite_error_001.phpt
deleted file mode 100644
index 0418086e9e..0000000000
--- a/ext/spl/tests/SplFileObject_fwrite_error_001.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-SplFileObject::fpassthru function - parameters test
---FILE--
-<?php
-$obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
-$obj->fwrite();
-$obj->fwrite('6,6,6',25,null);
-?>
---EXPECTF--
-Warning: SplFileObject::fwrite() expects at least 1 parameter, 0 given in %s
-
-Warning: SplFileObject::fwrite() expects at most 2 parameters, 3 given in %s
diff --git a/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt b/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt
index 61741a8bf5..a8e36cd046 100644
--- a/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt
+++ b/ext/spl/tests/SplFileObject_fwrite_variation_001.phpt
@@ -2,7 +2,7 @@
SplFileObject::fwrite function - writing with two parameters length < input string length
--FILE--
<?php
-$file = dirname(__FILE__).'/SplFileObject_fwrite_variation_001.txt';
+$file = __DIR__.'/SplFileObject_fwrite_variation_001.txt';
if(file_exists($file)) {
unlink($file);
}
@@ -12,7 +12,7 @@ var_dump(file_get_contents($file));
?>
--CLEAN--
<?php
-$file = dirname(__FILE__).'/SplFileObject_fwrite_variation_001.txt';
+$file = __DIR__.'/SplFileObject_fwrite_variation_001.txt';
if(file_exists($file)) {
unlink($file);
}
diff --git a/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt b/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt
index 31399a0d02..cea92a349c 100644
--- a/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt
+++ b/ext/spl/tests/SplFileObject_fwrite_variation_002.phpt
@@ -2,7 +2,7 @@
SplFileObject::fwrite function - writing with two parameters, length > input string length
--FILE--
<?php
-$file = dirname(__FILE__).'/SplFileObject_fwrite_variation_002.txt';
+$file = __DIR__.'/SplFileObject_fwrite_variation_002.txt';
if(file_exists($file)) {
unlink($file);
}
@@ -12,7 +12,7 @@ var_dump(file_get_contents($file));
?>
--CLEAN--
<?php
-$file = dirname(__FILE__).'/SplFileObject_fwrite_variation_002.txt';
+$file = __DIR__.'/SplFileObject_fwrite_variation_002.txt';
if(file_exists($file)) {
unlink($file);
}
diff --git a/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt b/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt
index 5c65a1b76b..97af917cb2 100644
--- a/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt
+++ b/ext/spl/tests/SplFileObject_getCsvControl_basic_001.phpt
@@ -2,7 +2,7 @@
SplFileObject::getCsvControl function - basic test
--FILE--
<?php
-$obj = New SplFileObject(dirname(__FILE__).'/SplFileObject_testinput.csv');
+$obj = New SplFileObject(__DIR__.'/SplFileObject_testinput.csv');
var_dump($obj->getCsvControl());
?>
diff --git a/ext/spl/tests/SplFileObject_getchildren_error001.phpt b/ext/spl/tests/SplFileObject_getchildren_error001.phpt
deleted file mode 100644
index 9c17a82977..0000000000
--- a/ext/spl/tests/SplFileObject_getchildren_error001.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-SPL: SplFileObject::getchildren error 001
---CREDITS--
-Erwin Poeze <erwin.poeze at gmail.com>
---FILE--
-<?php
-$s = new SplFileObject( __FILE__ );
-$s->getChildren('string');
-
-?>
---EXPECTF--
-Warning: SplFileObject::getChildren() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_getflags_error002.phpt b/ext/spl/tests/SplFileObject_getflags_error002.phpt
deleted file mode 100644
index 00fd351db8..0000000000
--- a/ext/spl/tests/SplFileObject_getflags_error002.phpt
+++ /dev/null
@@ -1,21 +0,0 @@
---TEST--
-SPL: SplFileObject::getFlags error 001
---CREDITS--
-Erwin Poeze <erwin.poeze@gmail.com>
---FILE--
-<?php
-
-file_put_contents('SplFileObject_getflags_error002.csv', 'eerste;tweede;derde');
-
-$fo = new SplFileObject('SplFileObject_getflags_error002.csv');
-$fo->setFlags(SplFileObject::READ_CSV);
-
-$fo->getFlags('fake');
-
-?>
---CLEAN--
-<?php
-unlink('SplFileObject_getflags_error002.csv');
-?>
---EXPECTF--
-Warning: SplFileObject::getFlags() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_haschildren_error001.phpt b/ext/spl/tests/SplFileObject_haschildren_error001.phpt
deleted file mode 100644
index 0c4e1de3b7..0000000000
--- a/ext/spl/tests/SplFileObject_haschildren_error001.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-SPL: SplFileObject::haschildren error 001
---CREDITS--
-Erwin Poeze <erwin.poeze at gmail.com>
---FILE--
-<?php
-$s = new SplFileObject( __FILE__ );
-$s->hasChildren('string');
-
-?>
---EXPECTF--
-Warning: SplFileObject::hasChildren() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_key_error003.phpt b/ext/spl/tests/SplFileObject_key_error003.phpt
deleted file mode 100644
index 7568cf55f4..0000000000
--- a/ext/spl/tests/SplFileObject_key_error003.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-SPL: SplFileObject::key error
---CREDITS--
-Erwin Poeze <erwin.poeze AT gmail.com>
---FILE--
-<?php
-//line 2
-//line 3
-//line 4
-//line 5
-$s = new SplFileObject(__FILE__);
-$s->key(3);
-?>
---EXPECTF--
-Warning: SplFileObject::key() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_rewind_error001.phpt b/ext/spl/tests/SplFileObject_rewind_error001.phpt
deleted file mode 100644
index 2e4aefb7a7..0000000000
--- a/ext/spl/tests/SplFileObject_rewind_error001.phpt
+++ /dev/null
@@ -1,22 +0,0 @@
---TEST--
-SPL: SplFileObject::rewind() with a parameter.
---CREDITS--
-Ricardo Oedietram <ricardo@odracir.nl>
-Erwin Poeze <erwin.poeze@gmail.com>
-#PFZ June PHP TestFest 2012
---FILE--
-<?php
-
-file_put_contents('SplFileObject_rewind_error001.csv', 'eerste;tweede;derde');
-
-$fo = new SplFileObject('SplFileObject_rewind_error001.csv');
-
-$fo->rewind( "invalid" );
-
-?>
---CLEAN--
-<?php
-unlink('SplFileObject_rewind_error001.csv');
-?>
---EXPECTF--
-Warning: SplFileObject::rewind() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt
index c7f4710868..c2eb623be9 100644
--- a/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt
+++ b/ext/spl/tests/SplFileObject_setCsvControl_basic.phpt
@@ -4,14 +4,14 @@ SPL: SplFileObject::setCsvControl basic
Erwin Poeze <erwin.poeze at gmail.com>
--FILE--
<?php
-file_put_contents('csv_control_data.csv',
+file_put_contents('csv_control_data_basic.csv',
<<<CDATA
'groene appelen'|10
'gele bananen'|20
'rode kersen'|30
CDATA
);
-$s = new SplFileObject('csv_control_data.csv');
+$s = new SplFileObject('csv_control_data_basic.csv');
$s->setFlags(SplFileObject::READ_CSV);
$s->setCsvControl('|', '\'', '/');
foreach ($s as $row) {
@@ -21,7 +21,7 @@ foreach ($s as $row) {
?>
--CLEAN--
<?php
-unlink('csv_control_data.csv');
+unlink('csv_control_data_basic.csv');
?>
--EXPECT--
groene appelen : 10
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt
index 384fed5d23..296c4a1aa0 100644
--- a/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt
+++ b/ext/spl/tests/SplFileObject_setCsvControl_error001.phpt
@@ -4,20 +4,20 @@ SPL: SplFileObject::setCsvControl error 001
Erwin Poeze <erwin.poeze at gmail.com>
--FILE--
<?php
-file_put_contents('csv_control_data.csv',
+file_put_contents('csv_control_data_error001.csv',
<<<CDATA
'groene appelen'|10
'gele bananen'|20
'rode kersen'|30
CDATA
);
-$s = new SplFileObject('csv_control_data.csv');
+$s = new SplFileObject('csv_control_data_error001.csv');
$s->setFlags(SplFileObject::READ_CSV);
$s->setCsvControl('||');
?>
--CLEAN--
<?php
-unlink('csv_control_data.csv');
+unlink('csv_control_data_error001.csv');
?>
--EXPECTF--
Warning: SplFileObject::setCsvControl(): delimiter must be a character in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt
index 6452212ee7..885d600225 100644
--- a/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt
+++ b/ext/spl/tests/SplFileObject_setCsvControl_error002.phpt
@@ -4,20 +4,20 @@ SPL: SplFileObject::setCsvControl error 002
Erwin Poeze <erwin.poeze at gmail.com>
--FILE--
<?php
-file_put_contents('csv_control_data.csv',
+file_put_contents('csv_control_data_error002.csv',
<<<CDATA
'groene appelen'|10
'gele bananen'|20
'rode kersen'|30
CDATA
);
-$s = new SplFileObject('csv_control_data.csv');
+$s = new SplFileObject('csv_control_data_error002.csv');
$s->setFlags(SplFileObject::READ_CSV);
$s->setCsvControl('|', 'two');
?>
--CLEAN--
<?php
-unlink('csv_control_data.csv');
+unlink('csv_control_data_error002.csv');
?>
--EXPECTF--
Warning: SplFileObject::setCsvControl(): enclosure must be a character in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt b/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt
index 927172a8dc..9e885cbbe3 100644
--- a/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt
+++ b/ext/spl/tests/SplFileObject_setCsvControl_error003.phpt
@@ -6,20 +6,20 @@ Erwin Poeze <erwin.poeze at gmail.com>
include_path=.
--FILE--
<?php
-file_put_contents('csv_control_data.csv',
+file_put_contents('csv_control_data_error003.csv',
<<<CDATA
'groene appelen'|10
'gele bananen'|20
'rode kersen'|30
CDATA
);
-$s = new SplFileObject('csv_control_data.csv');
+$s = new SplFileObject('csv_control_data_error003.csv');
$s->setFlags(SplFileObject::READ_CSV);
$s->setCsvControl('|', '\'', 'three');
?>
--CLEAN--
<?php
-unlink('csv_control_data.csv');
+unlink('csv_control_data_error003.csv');
?>
--EXPECTF--
-Warning: SplFileObject::setCsvControl(): escape must be a character in %s on line %d
+Warning: SplFileObject::setCsvControl(): escape must be empty or a single character in %s on line %d
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt
index c6da6b3d48..f54f8eeabd 100644
--- a/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt
+++ b/ext/spl/tests/SplFileObject_setCsvControl_variation001.phpt
@@ -4,14 +4,14 @@ SPL: SplFileObject::setCsvControl variation 001
Erwin Poeze <erwin.poeze at gmail.com>
--FILE--
<?php
-file_put_contents('csv_control_data.csv',
+file_put_contents('csv_control_data_variation001.csv',
<<<CDATA
"groene appelen",10
"gele bananen",20
"rode kersen",30
CDATA
);
-$s = new SplFileObject('csv_control_data.csv');
+$s = new SplFileObject('csv_control_data_variation001.csv');
$s->setFlags(SplFileObject::READ_CSV);
$s->setCsvControl();
foreach ($s as $row) {
@@ -21,7 +21,7 @@ foreach ($s as $row) {
?>
--CLEAN--
<?php
-unlink('csv_control_data.csv');
+unlink('csv_control_data_variation001.csv');
?>
--EXPECT--
groene appelen : 10
diff --git a/ext/spl/tests/SplFileObject_setCsvControl_variation002.phpt b/ext/spl/tests/SplFileObject_setCsvControl_variation002.phpt
new file mode 100644
index 0000000000..6d3a76ce94
--- /dev/null
+++ b/ext/spl/tests/SplFileObject_setCsvControl_variation002.phpt
@@ -0,0 +1,19 @@
+--TEST--
+SplFileObject::setCsvControl() and ::getCsvControl() with empty $escape
+--FILE--
+<?php
+$file = new SplTempFileObject;
+$file->setCsvControl(',', '"', '');
+var_dump($file->getCsvControl());
+?>
+===DONE===
+--EXPECT--
+array(3) {
+ [0]=>
+ string(1) ","
+ [1]=>
+ string(1) """
+ [2]=>
+ string(0) ""
+}
+===DONE===
diff --git a/ext/spl/tests/SplFixedArray_count_checkParams.phpt b/ext/spl/tests/SplFixedArray_count_checkParams.phpt
deleted file mode 100644
index 5cb12feee7..0000000000
--- a/ext/spl/tests/SplFixedArray_count_checkParams.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-Makes sure that an integer cannot be passed into the count() method of the splFixedArray.
---CREDITS--
-PHPNW Test Fest 2009 - Rick Ogden
---FILE--
-<?php
-$ar = new SplFixedArray(3);
-$ar[0] = 1;
-$ar[1] = 2;
-$ar[2] = 3;
-
-echo $ar->count(3);
-?>
---EXPECTF--
-Warning: SplFixedArray::count() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_count_param_int.phpt b/ext/spl/tests/SplFixedArray_count_param_int.phpt
deleted file mode 100644
index 0cb4d06fdd..0000000000
--- a/ext/spl/tests/SplFixedArray_count_param_int.phpt
+++ /dev/null
@@ -1,11 +0,0 @@
---TEST--
-Creates array, uses the count function to get the size of the array, but passes a parameter.
---CREDITS--
-Philip Norton philipnorton42@gmail.com
---FILE--
-<?php
-$array = new SplFixedArray(5);
-echo $array->count(3);
-?>
---EXPECTF--
-Warning: SplFixedArray::count() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_current_param.phpt b/ext/spl/tests/SplFixedArray_current_param.phpt
deleted file mode 100644
index 71f5d3a524..0000000000
--- a/ext/spl/tests/SplFixedArray_current_param.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-SplFixedArray::current() with a parameter. *BUG*
---CREDITS--
-PHPNW Test Fest 2009 - Jordan Hatch
---FILE--
-<?php
-
-$array = new SplFixedArray( 3 );
-
-$array[0] = "Hello";
-$array[1] = "world";
-$array[2] = "elePHPant";
-
-foreach ( $array as $value ) {
- echo $array->current( array("this","should","not","execute") );
-}
-
-?>
---EXPECTF--
-Warning: SplFixedArray::current() expects exactly 0 parameters, 1 given in %s on line %d
-
-Warning: SplFixedArray::current() expects exactly 0 parameters, 1 given in %s on line %d
-
-Warning: SplFixedArray::current() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_001.phpt b/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_001.phpt
deleted file mode 100644
index 3cecb8b79c..0000000000
--- a/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_001.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-pass an integer into fromArray()
---CREDITS--
-PHPNW Testfest 2009 - Lorna Mitchell
---FILE--
-<?php
-echo SplFixedArray::fromArray(17954);
-?>
---EXPECTF--
-Warning: SplFixedArray::fromArray() expects parameter 1 to be array, int given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_002.phpt b/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_002.phpt
deleted file mode 100644
index a0747451a0..0000000000
--- a/ext/spl/tests/SplFixedArray_fromArray_invalid_parameter_002.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-pass a string into fromArray()
---CREDITS--
-PHPNW Testfest 2009 - Lorna Mitchell
---FILE--
-<?php
-echo SplFixedArray::fromArray('hello');
-?>
---EXPECTF--
-Warning: SplFixedArray::fromArray() expects parameter 1 to be array, string given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt b/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt
index ea7022419c..c649e3b6c3 100644
--- a/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt
+++ b/ext/spl/tests/SplFixedArray_fromarray_indexes.phpt
@@ -9,7 +9,7 @@ $array = SplFixedArray::fromArray(array(1 => 1,
3 => false));
var_dump($array);
?>
---EXPECTF--
+--EXPECT--
object(SplFixedArray)#1 (4) {
[0]=>
NULL
diff --git a/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt b/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt
index 10985bbeab..b3e7497397 100644
--- a/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt
+++ b/ext/spl/tests/SplFixedArray_fromarray_non_indexes.phpt
@@ -10,7 +10,7 @@ $array = SplFixedArray::fromArray(array(1 => 1,
false);
var_dump($array);
?>
---EXPECTF--
+--EXPECT--
object(SplFixedArray)#1 (3) {
[0]=>
int(1)
diff --git a/ext/spl/tests/SplFixedArray_fromarray_param_boolean.phpt b/ext/spl/tests/SplFixedArray_fromarray_param_boolean.phpt
deleted file mode 100644
index 5c8f526d66..0000000000
--- a/ext/spl/tests/SplFixedArray_fromarray_param_boolean.phpt
+++ /dev/null
@@ -1,10 +0,0 @@
---TEST--
-Tries to create a SplFixedArray using a boolean value.
---CREDITS--
-Philip Norton philipnorton42@gmail.com
---FILE--
-<?php
-$array = SplFixedArray::fromArray(true);
-?>
---EXPECTF--
-Warning: SplFixedArray::fromArray() expects parameter 1 to be array, bool given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt b/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt
index b669563db4..e5329e03fc 100644
--- a/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt
+++ b/ext/spl/tests/SplFixedArray_fromarray_param_multiarray.phpt
@@ -7,7 +7,7 @@ Philip Norton philipnorton42@gmail.com
$array = SplFixedArray::fromArray(array(array('1')));
var_dump($array);
?>
---EXPECTF--
+--EXPECT--
object(SplFixedArray)#1 (1) {
[0]=>
array(1) {
diff --git a/ext/spl/tests/SplFixedArray_getSize_pass_param.phpt b/ext/spl/tests/SplFixedArray_getSize_pass_param.phpt
deleted file mode 100644
index ef4f40c32f..0000000000
--- a/ext/spl/tests/SplFixedArray_getSize_pass_param.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-SplFixedArray::getSize() pass a parameter when none are expected
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
-$fixed_array = new SplFixedArray(2);
-echo "*test* ".$fixed_array->getSize(3);
-?>
---EXPECTF--
-Warning: SplFixedArray::getSize() expects exactly 0 parameters, 1 given in %s on line %d
-*test*
diff --git a/ext/spl/tests/SplFixedArray_key_param.phpt b/ext/spl/tests/SplFixedArray_key_param.phpt
deleted file mode 100644
index 300e6df790..0000000000
--- a/ext/spl/tests/SplFixedArray_key_param.phpt
+++ /dev/null
@@ -1,24 +0,0 @@
---TEST--
-SplFixedArray::key() with a parameter passed. This is a bug and an error should be called.
---CREDITS--
-PHPNW Test Fest 2009 - Jordan Hatch
---FILE--
-<?php
-
-$array = new SplFixedArray( 3 );
-
-$array[0] = "Hello";
-$array[1] = "world";
-$array[2] = "elePHPant";
-
-foreach ( $array as $value ) {
- echo $array->key( array("this","should","not","execute") );
-}
-
-?>
---EXPECTF--
-Warning: SplFixedArray::key() expects exactly 0 parameters, 1 given in %s on line %d
-
-Warning: SplFixedArray::key() expects exactly 0 parameters, 1 given in %s on line %d
-
-Warning: SplFixedArray::key() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_next_param.phpt b/ext/spl/tests/SplFixedArray_next_param.phpt
deleted file mode 100644
index 5e8cb633b9..0000000000
--- a/ext/spl/tests/SplFixedArray_next_param.phpt
+++ /dev/null
@@ -1,18 +0,0 @@
---TEST--
-SplFixedArray::next() with a parameter. *BUG*
---CREDITS--
-PHPNW Test Fest 2009 - Jordan Hatch
---FILE--
-<?php
-
-$array = new SplFixedArray( 4 );
-
-$array[0] = "Hello";
-$array[1] = "world";
-$array[2] = "elePHPant";
-
-$array->next( "invalid" );
-
-?>
---EXPECTF--
-Warning: SplFixedArray::next() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_offsetExists_invalid_parameter.phpt b/ext/spl/tests/SplFixedArray_offsetExists_invalid_parameter.phpt
deleted file mode 100644
index 76ee2f58ad..0000000000
--- a/ext/spl/tests/SplFixedArray_offsetExists_invalid_parameter.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-SPL FixedArray offsetExists throws error only one parameter
---CREDITS--
-PHPNW TestFest 2009 - Ben Longden
---FILE--
-<?php
-$array = new SplFixedArray(5);
-$a = $array->offsetExists();
-if(is_null($a)) {
- echo 'PASS';
-}
-?>
---EXPECTF--
-Warning: SplFixedArray::offsetExists() expects exactly 1 parameter, 0 given in %s on line %d
-PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetGet_invalid_parameter.phpt b/ext/spl/tests/SplFixedArray_offsetGet_invalid_parameter.phpt
deleted file mode 100644
index 71a1bf80f2..0000000000
--- a/ext/spl/tests/SplFixedArray_offsetGet_invalid_parameter.phpt
+++ /dev/null
@@ -1,16 +0,0 @@
---TEST--
-SPL FixedArray offsetGet throws error on no parameter
---CREDITS--
-PHPNW TestFest 2009 - Ben Longden
---FILE--
-<?php
-$array = new SplFixedArray(5);
-$array[0] = 'a';
-$a = $array->offsetGet();
-if(is_null($a)) {
- echo 'PASS';
-}
-?>
---EXPECTF--
-Warning: SplFixedArray::offsetGet() expects exactly 1 parameter, 0 given in %s on line %d
-PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetSet_invalid_parameter.phpt b/ext/spl/tests/SplFixedArray_offsetSet_invalid_parameter.phpt
deleted file mode 100644
index 4e43a525fc..0000000000
--- a/ext/spl/tests/SplFixedArray_offsetSet_invalid_parameter.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-SPL FixedArray offsetSet throws error on no parameters
---CREDITS--
-PHPNW TestFest 2009 - Ben Longden
---FILE--
-<?php
-$array = new SplFixedArray(5);
-$a = $array->offsetSet();
-if(is_null($a)) {
- echo 'PASS';
-}
-?>
---EXPECTF--
-Warning: SplFixedArray::offsetSet() expects exactly 2 parameters, 0 given in %s on line %d
-PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetSet_one_invalid_parameter.phpt b/ext/spl/tests/SplFixedArray_offsetSet_one_invalid_parameter.phpt
deleted file mode 100644
index c19cd01763..0000000000
--- a/ext/spl/tests/SplFixedArray_offsetSet_one_invalid_parameter.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-SPL FixedArray offsetSet throws error only one parameter
---CREDITS--
-PHPNW TestFest 2009 - Ben Longden
---FILE--
-<?php
-$array = new SplFixedArray(5);
-$a = $array->offsetSet(2);
-if(is_null($a)) {
- echo 'PASS';
-}
-?>
---EXPECTF--
-Warning: SplFixedArray::offsetSet() expects exactly 2 parameters, 1 given in %s on line %d
-PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetUnset_invalid_parameter.phpt b/ext/spl/tests/SplFixedArray_offsetUnset_invalid_parameter.phpt
deleted file mode 100644
index 40a372bd91..0000000000
--- a/ext/spl/tests/SplFixedArray_offsetUnset_invalid_parameter.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-SPL FixedArray offsetUnset throws error on no parameter
---CREDITS--
-PHPNW TestFest 2009 - Ben Longden
---FILE--
-<?php
-$array = new SplFixedArray(5);
-$a = $array->offsetUnset();
-if(is_null($a)) {
- echo 'PASS';
-}
-?>
---EXPECTF--
-Warning: SplFixedArray::offsetUnset() expects exactly 1 parameter, 0 given in %s on line %d
-PASS
diff --git a/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt b/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt
index cc054dff3c..3b0e6bb222 100644
--- a/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt
+++ b/ext/spl/tests/SplFixedArray_offsetUnset_string.phpt
@@ -18,7 +18,7 @@ PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
var_dump($fixedArray);
?>
---EXPECTF--
+--EXPECT--
object(SplFixedArray)#1 (5) {
[0]=>
string(14) "PHPNW Testfest"
diff --git a/ext/spl/tests/SplFixedArray_rewind_param.phpt b/ext/spl/tests/SplFixedArray_rewind_param.phpt
deleted file mode 100644
index 7002efb313..0000000000
--- a/ext/spl/tests/SplFixedArray_rewind_param.phpt
+++ /dev/null
@@ -1,18 +0,0 @@
---TEST--
-SplFixedArray::rewind() with a parameter. *BUG*
---CREDITS--
-PHPNW Test Fest 2009 - Jordan Hatch
---FILE--
-<?php
-
-$array = new SplFixedArray( 4 );
-
-$array[0] = "Hello";
-$array[1] = "world";
-$array[2] = "elePHPant";
-
-$array->rewind( "invalid" );
-
-?>
---EXPECTF--
-Warning: SplFixedArray::rewind() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/SplFixedArray_setSize_param_array.phpt b/ext/spl/tests/SplFixedArray_setSize_param_array.phpt
deleted file mode 100644
index a9e763ab83..0000000000
--- a/ext/spl/tests/SplFixedArray_setSize_param_array.phpt
+++ /dev/null
@@ -1,18 +0,0 @@
---TEST--
-SplFixedArray::setSize() with an array parameter
---CREDITS--
-PHPNW Testfest 2009 - Adrian Hardy
---FILE--
-<?php
-$fixed_array = new SplFixedArray(2);
-$fixed_array->setSize(array());
-var_dump($fixed_array);
-?>
---EXPECTF--
-Warning: SplFixedArray::setSize() expects parameter 1 to be int, array given in %s on line %d
-object(SplFixedArray)#1 (2) {
- [0]=>
- NULL
- [1]=>
- NULL
-}
diff --git a/ext/spl/tests/SplFixedArray_setsize_001.phpt b/ext/spl/tests/SplFixedArray_setsize_001.phpt
index d9c1469ee2..b6fd2f1e4e 100644
--- a/ext/spl/tests/SplFixedArray_setsize_001.phpt
+++ b/ext/spl/tests/SplFixedArray_setsize_001.phpt
@@ -13,7 +13,7 @@ $array[4] = 'five';
$array->setSize(2);
var_dump($array);
?>
---EXPECTF--
+--EXPECT--
object(SplFixedArray)#1 (2) {
[0]=>
string(3) "one"
diff --git a/ext/spl/tests/SplFixedArray_toArray_with-params.phpt b/ext/spl/tests/SplFixedArray_toArray_with-params.phpt
deleted file mode 100644
index 4c72dca235..0000000000
--- a/ext/spl/tests/SplFixedArray_toArray_with-params.phpt
+++ /dev/null
@@ -1,19 +0,0 @@
---TEST--
-Check that passing a parameter to toArray() produces a correct error
---CREDITS--
-PHPNW Testfest 2009 - Paul Court ( g@rgoyle.com )
---FILE--
-<?php
- // Create a fixed array
- $fixedArray = new SplFixedArray(5);
-
- // Fill it up
- for ($i=0; $i < 5; $i++) {
- $fixedArray[$i] = "PHPNW Testfest";
- }
-
- // Test count() returns correct error when parameters are passed.
- $fixedArray->count(1);
-?>
---EXPECTF--
-Warning: SplFixedArray::count() expects exactly 0 parameters, %d given in %s on line %d
diff --git a/ext/spl/tests/SplHeap_count_invalid_parameter.phpt b/ext/spl/tests/SplHeap_count_invalid_parameter.phpt
deleted file mode 100644
index e8b122ec10..0000000000
--- a/ext/spl/tests/SplHeap_count_invalid_parameter.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-Check that SplHeap::count generate a warning and returns NULL when param passed
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- new stdClass,
- array(),
- true,
- "string",
- 12345,
- 1.2345,
- NULL
-);
-
-foreach($data_provider as $input) {
-
- $h = new SplMaxHeap();
-
- var_dump($h->count($input));
-}
-
-?>
---EXPECTF--
-Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::count() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplHeap_extract_invalid_parameter.phpt b/ext/spl/tests/SplHeap_extract_invalid_parameter.phpt
deleted file mode 100644
index d3c9f76589..0000000000
--- a/ext/spl/tests/SplHeap_extract_invalid_parameter.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-Check that SplHeap::extract generate a warning and returns NULL when param passed
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- new stdClass,
- array(),
- true,
- "string",
- 12345,
- 1.2345,
- NULL
-);
-
-foreach($data_provider as $input) {
-
- $h = new SplMaxHeap();
-
- var_dump($h->extract($input));
-}
-
-?>
---EXPECTF--
-Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplHeap_insert_invalid_parameter.phpt b/ext/spl/tests/SplHeap_insert_invalid_parameter.phpt
deleted file mode 100644
index f2bec5a66f..0000000000
--- a/ext/spl/tests/SplHeap_insert_invalid_parameter.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-Check that SplHeap::insert generate a warning and returns NULL when $value is missing
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$h = new SplMaxHeap();
-
-var_dump($h->insert());
-
-?>
---EXPECTF--
-Warning: SplHeap::insert() expects exactly 1 parameter, 0 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplHeap_isEmpty_invalid_parameter.phpt b/ext/spl/tests/SplHeap_isEmpty_invalid_parameter.phpt
deleted file mode 100644
index f98a69cadf..0000000000
--- a/ext/spl/tests/SplHeap_isEmpty_invalid_parameter.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-Check that SplHeap::isEmpty generate a warning and returns NULL when param passed
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- new stdClass,
- array(),
- true,
- "string",
- 12345,
- 1.2345,
- NULL
-);
-
-foreach($data_provider as $input) {
-
- $h = new SplMaxHeap();
-
- var_dump($h->isEmpty($input));
-}
-
-?>
---EXPECTF--
-Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplObjectStorage_addAll_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_addAll_invalid_parameter.phpt
deleted file mode 100644
index 3401439d97..0000000000
--- a/ext/spl/tests/SplObjectStorage_addAll_invalid_parameter.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Check that SplObjectStorage::addAll generate a warning and returns NULL when passed non-object param
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- array(),
- true,
- "string",
- 12345,
- 1.2345,
- NULL
-);
-
-foreach($data_provider as $input) {
-
- $s = new SplObjectStorage();
-
- var_dump($s->addAll($input));
-}
-
-?>
---EXPECTF--
-Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, array given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, bool given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, string given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, int given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, float given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::addAll() expects parameter 1 to be SplObjectStorage, null given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt
deleted file mode 100644
index a6e68854da..0000000000
--- a/ext/spl/tests/SplObjectStorage_attach_invalid_parameter.phpt
+++ /dev/null
@@ -1,19 +0,0 @@
---TEST--
-Check that SplObjectStorage::attach generates a warning and returns NULL when bad params are passed
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$s = new SplObjectStorage();
-
-var_dump($s->attach(true));
-var_dump($s->attach(new stdClass, true, true));
-
-?>
---EXPECTF--
-Warning: SplObjectStorage::attach() expects parameter 1 to be object, bool given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::attach() expects at most 2 parameters, 3 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt
deleted file mode 100644
index 0f21923949..0000000000
--- a/ext/spl/tests/SplObjectStorage_contains_invalid_parameter.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Check that SplObjectStorage::contains generate a warning and returns NULL when passed non-object param
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- array(),
- true,
- "string",
- 12345,
- 1.2345,
- NULL
-);
-
-foreach($data_provider as $input) {
-
- $s = new SplObjectStorage();
-
- var_dump($s->contains($input));
-}
-
-?>
---EXPECTF--
-Warning: SplObjectStorage::contains() expects parameter 1 to be object, array given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::contains() expects parameter 1 to be object, bool given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::contains() expects parameter 1 to be object, string given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::contains() expects parameter 1 to be object, int given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::contains() expects parameter 1 to be object, float given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::contains() expects parameter 1 to be object, null given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt
deleted file mode 100644
index 6b4a8f798f..0000000000
--- a/ext/spl/tests/SplObjectStorage_detach_invalid_parameter.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Check that SplObjectStorage::detach generate a warning and returns NULL when passed non-object param
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- array(),
- true,
- "string",
- 12345,
- 1.2345,
- NULL
-);
-
-foreach($data_provider as $input) {
-
- $s = new SplObjectStorage();
-
- var_dump($s->detach($input));
-}
-
-?>
---EXPECTF--
-Warning: SplObjectStorage::detach() expects parameter 1 to be object, array given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::detach() expects parameter 1 to be object, bool given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::detach() expects parameter 1 to be object, string given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::detach() expects parameter 1 to be object, int given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::detach() expects parameter 1 to be object, float given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::detach() expects parameter 1 to be object, null given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplObjectStorage_offsetGet_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_offsetGet_invalid_parameter.phpt
deleted file mode 100644
index 7561bc0765..0000000000
--- a/ext/spl/tests/SplObjectStorage_offsetGet_invalid_parameter.phpt
+++ /dev/null
@@ -1,44 +0,0 @@
---TEST--
-Check that SplObjectStorage::offsetGet generate a warning and return NULL when passed non-object param
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- array(),
- true,
- "string",
- 12345,
- 1.2345,
- NULL
-);
-
-foreach($data_provider as $input) {
-
- $s = new SplObjectStorage();
- $o1 = new stdClass();
- $s[$o1] = 'some_value';
-
- var_dump($s->offsetGet($input));
-}
-
-?>
---EXPECTF--
-Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, array given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, bool given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, string given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, int given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, float given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::offsetGet() expects parameter 1 to be object, null given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplObjectStorage_removeAllExcept_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_removeAllExcept_invalid_parameter.phpt
deleted file mode 100644
index fe5b63d07e..0000000000
--- a/ext/spl/tests/SplObjectStorage_removeAllExcept_invalid_parameter.phpt
+++ /dev/null
@@ -1,43 +0,0 @@
---TEST--
-Check that SplObjectStorage::removeAllExcept generate a warning and returns NULL when passed non-object param
---CREDITS--
-Matthew Turland (me@matthewturland.com)
-Based on work done at PHPNW Testfest 2009 by Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- array(),
- true,
- "string",
- 12345,
- 1.2345,
- NULL
-);
-
-foreach($data_provider as $input) {
-
- $s = new SplObjectStorage();
-
- var_dump($s->removeAllExcept($input));
-}
-
-?>
---EXPECTF--
-Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, array given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, bool given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, string given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, int given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, float given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::removeAllExcept() expects parameter 1 to be SplObjectStorage, null given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplObjectStorage_removeAll_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_removeAll_invalid_parameter.phpt
deleted file mode 100644
index a1c6f938b2..0000000000
--- a/ext/spl/tests/SplObjectStorage_removeAll_invalid_parameter.phpt
+++ /dev/null
@@ -1,42 +0,0 @@
---TEST--
-Check that SplObjectStorage::removeAll generate a warning and returns NULL when passed non-object param
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- array(),
- true,
- "string",
- 12345,
- 1.2345,
- NULL
-);
-
-foreach($data_provider as $input) {
-
- $s = new SplObjectStorage();
-
- var_dump($s->removeAll($input));
-}
-
-?>
---EXPECTF--
-Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, array given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, bool given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, string given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, int given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, float given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::removeAll() expects parameter 1 to be SplObjectStorage, null given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplObjectStorage_setInfo_invalid_parameter.phpt b/ext/spl/tests/SplObjectStorage_setInfo_invalid_parameter.phpt
deleted file mode 100644
index 939fd5d52d..0000000000
--- a/ext/spl/tests/SplObjectStorage_setInfo_invalid_parameter.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-Check that SplObjectStorage::setInfo returns NULL when no param is passed
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$s = new SplObjectStorage();
-
-var_dump($s->setInfo());
-
-?>
---EXPECTF--
-Warning: SplObjectStorage::setInfo() expects exactly 1 parameter, 0 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt b/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt
deleted file mode 100644
index 8eef31382d..0000000000
--- a/ext/spl/tests/SplObjectStorage_unserialize_invalid_parameter1.phpt
+++ /dev/null
@@ -1,26 +0,0 @@
---TEST--
-Check that SplObjectStorage::unserialize returns NULL when non-string param is passed
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- array(),
- new stdClass(),
-);
-
-foreach($data_provider as $input) {
-
- $s = new SplObjectStorage();
-
- var_dump($s->unserialize($input));
-}
-
-?>
---EXPECTF--
-Warning: SplObjectStorage::unserialize() expects parameter 1 to be string, array given in %s on line %d
-NULL
-
-Warning: SplObjectStorage::unserialize() expects parameter 1 to be string, object given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplObjectStorage_unserialize_nested.phpt b/ext/spl/tests/SplObjectStorage_unserialize_nested.phpt
index daf415049c..c75662c66e 100644
--- a/ext/spl/tests/SplObjectStorage_unserialize_nested.phpt
+++ b/ext/spl/tests/SplObjectStorage_unserialize_nested.phpt
@@ -18,7 +18,7 @@ echo $s."\n";
$so1 = unserialize($s);
var_dump($so1);
--EXPECTF--
-C:16:"SplObjectStorage":76:{x:i:2;O:8:"stdClass":1:{s:1:"a";O:8:"stdClass":0:{}},i:1;;r:4;,i:2;;m:a:0:{}}
+O:16:"SplObjectStorage":2:{i:0;a:4:{i:0;O:8:"stdClass":1:{s:1:"a";O:8:"stdClass":0:{}}i:1;i:1;i:2;r:4;i:3;i:2;}i:1;a:0:{}}
object(SplObjectStorage)#4 (1) {
["storage":"SplObjectStorage":private]=>
array(2) {
diff --git a/ext/spl/tests/SplPriorityQueue_extract_invalid_parameter.phpt b/ext/spl/tests/SplPriorityQueue_extract_invalid_parameter.phpt
deleted file mode 100644
index 79b75ae4a0..0000000000
--- a/ext/spl/tests/SplPriorityQueue_extract_invalid_parameter.phpt
+++ /dev/null
@@ -1,46 +0,0 @@
---TEST--
-Check that SplPriorityQueue::extract generate a warning and returns NULL when param passed
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$data_provider = array(
- new stdClass,
- array(),
- true,
- "string",
- 12345,
- 1.2345,
- NULL
-);
-
-foreach($data_provider as $input) {
-
- $h = new SplPriorityQueue();
-
- var_dump($h->extract($input));
-}
-
-?>
---EXPECTF--
-Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
-
-Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplPriorityQueue_insert_invalid_parameter.phpt b/ext/spl/tests/SplPriorityQueue_insert_invalid_parameter.phpt
deleted file mode 100644
index 08314fd74c..0000000000
--- a/ext/spl/tests/SplPriorityQueue_insert_invalid_parameter.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-Check that SplPriorityQueue::insert generate a warning and returns NULL when rubbish params are passed
---CREDITS--
-PHPNW Testfest 2009 - Simon Westcott (swestcott@gmail.com)
---FILE--
-<?php
-
-$h = new SplPriorityQueue();
-
-var_dump($h->insert(NULL));
-
-?>
---EXPECTF--
-Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 1 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/SplPriorityQueue_setExtractFlags_zero.phpt b/ext/spl/tests/SplPriorityQueue_setExtractFlags_zero.phpt
new file mode 100644
index 0000000000..cf2d339914
--- /dev/null
+++ b/ext/spl/tests/SplPriorityQueue_setExtractFlags_zero.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Setting SplPriorityQueue extract flags to zero generates an exception
+--FILE--
+<?php
+
+$queue = new SplPriorityQueue();
+$queue->setExtractFlags(0);
+
+?>
+--EXPECTF--
+Fatal error: Uncaught RuntimeException: Must specify at least one extract flag in %s:%d
+Stack trace:
+#0 %s(%d): SplPriorityQueue->setExtractFlags(0)
+#1 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt b/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt
index a749493007..e6e950c628 100644
--- a/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt
+++ b/ext/spl/tests/arrayObject_getIteratorClass_basic1.phpt
@@ -6,36 +6,36 @@ class MyIterator extends ArrayIterator {
function __construct() {
$args = func_get_args();
- echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ echo " In " . __METHOD__ . "(" . implode(',', $args) . ")\n";
}
function rewind() {
$args = func_get_args();
- echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ echo " In " . __METHOD__ . "(" . implode(',', $args) . ")\n";
return parent::rewind();
}
function valid() {
$args = func_get_args();
- echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ echo " In " . __METHOD__ . "(" . implode(',', $args) . ")\n";
return parent::valid();
}
function current() {
$args = func_get_args();
- echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ echo " In " . __METHOD__ . "(" . implode(',', $args) . ")\n";
return parent::current();
}
function next() {
$args = func_get_args();
- echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ echo " In " . __METHOD__ . "(" . implode(',', $args) . ")\n";
return parent::next();
}
function key() {
$args = func_get_args();
- echo " In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ echo " In " . __METHOD__ . "(" . implode(',', $args) . ")\n";
return parent::key();
}
}
diff --git a/ext/spl/tests/arrayObject_magicMethods5.phpt b/ext/spl/tests/arrayObject_magicMethods5.phpt
index a3c0581bc3..6d2ced3a71 100644
--- a/ext/spl/tests/arrayObject_magicMethods5.phpt
+++ b/ext/spl/tests/arrayObject_magicMethods5.phpt
@@ -16,19 +16,19 @@ class UsesMagic extends ArrayObject {
function __get($name) {
$args = func_get_args();
- echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ echo "In " . __METHOD__ . "(" . implode(',', $args) . ")\n";
}
function __set($name, $value) {
$args = func_get_args();
- echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ echo "In " . __METHOD__ . "(" . implode(',', $args) . ")\n";
}
function __isset($name) {
$args = func_get_args();
- echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ echo "In " . __METHOD__ . "(" . implode(',', $args) . ")\n";
}
function __unset($name) {
$args = func_get_args();
- echo "In " . __METHOD__ . "(" . implode($args, ',') . ")\n";
+ echo "In " . __METHOD__ . "(" . implode(',', $args) . ")\n";
}
}
diff --git a/ext/spl/tests/array_013.phpt b/ext/spl/tests/array_013.phpt
index 3aad7bf6f7..1f0c631c02 100644
--- a/ext/spl/tests/array_013.phpt
+++ b/ext/spl/tests/array_013.phpt
@@ -5,7 +5,7 @@ SPL: ArrayIterator::append
if (!class_exists('NoRewindIterator', false))
{
- require_once(dirname(__FILE__) . '/../examples/norewinditerator.inc');
+ require_once(__DIR__ . '/../examples/norewinditerator.inc');
}
echo "===Array===\n";
diff --git a/ext/spl/tests/array_017.phpt b/ext/spl/tests/array_017.phpt
index 30d2b70915..3074a76417 100644
--- a/ext/spl/tests/array_017.phpt
+++ b/ext/spl/tests/array_017.phpt
@@ -139,13 +139,17 @@ array(3) {
["Flags"]=>
int(0)
["OVars"]=>
- array(3) {
- [0]=>
- int(1)
- ["a"]=>
- int(25)
+ array(5) {
["pub1"]=>
- int(42)
+ int(1)
+ ["pro1"]=>
+ int(2)
+ ["pri1"]=>
+ int(3)
+ ["imp1"]=>
+ int(4)
+ ["dyn1"]=>
+ int(5)
}
["$this"]=>
object(ArrayObjectEx)#%d (6) {
@@ -178,13 +182,17 @@ array(3) {
["Flags"]=>
int(0)
["OVars"]=>
- array(3) {
- [0]=>
+ array(5) {
+ ["pub2"]=>
int(1)
- ["a"]=>
- int(25)
- ["pub1"]=>
- int(42)
+ ["pro2"]=>
+ int(2)
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
}
["$this"]=>
object(ArrayIteratorEx)#%d (6) {
@@ -242,13 +250,17 @@ array(3) {
["Flags"]=>
int(0)
["OVars"]=>
- array(3) {
- [0]=>
+ array(5) {
+ ["pub2"]=>
int(1)
- ["a"]=>
- int(25)
- ["pub1"]=>
- int(42)
+ ["pro2"]=>
+ int(2)
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
+ int(4)
+ ["dyn2"]=>
+ int(5)
}
["$this"]=>
object(ArrayIteratorEx)#%d (6) {
@@ -541,14 +553,16 @@ array(3) {
["Flags"]=>
int(0)
["OVars"]=>
- array(4) {
- ["pub1"]=>
+ array(5) {
+ ["pub2"]=>
int(1)
- ["pro1"]=>
+ ["pro2"]=>
int(2)
- ["imp1"]=>
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
int(4)
- ["dyn1"]=>
+ ["dyn2"]=>
int(5)
}
["$this"]=>
@@ -598,14 +612,16 @@ array(3) {
["Flags"]=>
int(0)
["OVars"]=>
- array(4) {
- ["pub1"]=>
+ array(5) {
+ ["pub2"]=>
int(1)
- ["pro1"]=>
+ ["pro2"]=>
int(2)
- ["imp1"]=>
+ ["pri2"]=>
+ int(3)
+ ["imp2"]=>
int(4)
- ["dyn1"]=>
+ ["dyn2"]=>
int(5)
}
["$this"]=>
diff --git a/ext/spl/tests/array_025.phpt b/ext/spl/tests/array_025.phpt
index 35893ea1ea..9a95de60eb 100644
--- a/ext/spl/tests/array_025.phpt
+++ b/ext/spl/tests/array_025.phpt
@@ -24,7 +24,7 @@ ArrayObject Object
)
)
-C:11:"ArrayObject":76:{x:i:0;C:11:"ArrayObject":37:{x:i:0;a:2:{i:0;i:1;i:1;i:2;};m:a:0:{}};m:a:0:{}}
+O:11:"ArrayObject":3:{i:0;i:0;i:1;O:11:"ArrayObject":3:{i:0;i:0;i:1;a:2:{i:0;i:1;i:1;i:2;}i:2;a:0:{}}i:2;a:0:{}}
ArrayObject Object
(
[storage:ArrayObject:private] => ArrayObject Object
diff --git a/ext/spl/tests/array_026.phpt b/ext/spl/tests/array_026.phpt
index 9c79c57b66..8ff6aafb93 100644
--- a/ext/spl/tests/array_026.phpt
+++ b/ext/spl/tests/array_026.phpt
@@ -8,8 +8,10 @@ $test['d1']['d3'] = 'world';
var_dump($test, $test3['mmmmm']);
?>
--EXPECTF--
-Notice: Undefined variable: test3 in %s%earray_026.php on line %d
-object(ArrayObject)#%d (1) {
+Notice: Undefined variable: test3 in %s on line %d
+
+Notice: Trying to access array offset on value of type null in %s on line %d
+object(ArrayObject)#1 (1) {
["storage":"ArrayObject":private]=>
array(1) {
["d1"]=>
diff --git a/ext/spl/tests/bug38618.phpt b/ext/spl/tests/bug38618.phpt
index 95a3da83cc..097d169a98 100644
--- a/ext/spl/tests/bug38618.phpt
+++ b/ext/spl/tests/bug38618.phpt
@@ -1,7 +1,7 @@
--TEST--
Bug #38618 (RecursiveArrayIterator::hasChildren() follows objects)
--FILE--
-<?php # vim:ft=php
+<?php
class FruitPublic
{
diff --git a/ext/spl/tests/bug42364.phpt b/ext/spl/tests/bug42364.phpt
index 971fcc5ebb..4d00a18222 100644
--- a/ext/spl/tests/bug42364.phpt
+++ b/ext/spl/tests/bug42364.phpt
@@ -2,10 +2,12 @@
Bug #42364 (Crash when using getRealPath with DirectoryIterator)
--FILE--
<?php
-$it = new DirectoryIterator(dirname(__FILE__));
+$dir = __DIR__ . '/bug42364';
+@mkdir($dir);
+touch($dir . '/test');
$count = 0;
-
+$it = new DirectoryIterator($dir);
foreach ($it as $e) {
$count++;
$type = gettype($e->getRealPath());
@@ -19,6 +21,11 @@ if ($count > 0) {
}
?>
===DONE===
+--CLEAN--
+<?php
+unlink(__DIR__ . '/bug42364/test');
+rmdir(__DIR__ . '/bug42364');
+?>
--EXPECTF--
Found %i entries!
===DONE===
diff --git a/ext/spl/tests/bug45216.phpt b/ext/spl/tests/bug45216.phpt
index 31e6d62352..e8b04cb1fb 100644
--- a/ext/spl/tests/bug45216.phpt
+++ b/ext/spl/tests/bug45216.phpt
@@ -5,7 +5,7 @@ Perrick Penet <perrick@noparking.net>
#testfest phpcampparis 2008-06-07
--FILE--
<?php
-$file = dirname(__FILE__) . '/foo.html';
+$file = __DIR__ . '/foo.html';
file_put_contents($file, 'text 0<div class="tested">text 1</div>');
$handle = fopen($file, 'r');
@@ -15,7 +15,7 @@ var_dump(fgetss($handle));
?>
--CLEAN--
<?php
-unlink(dirname(__FILE__) . '/foo.html');
+unlink(__DIR__ . '/foo.html');
?>
--EXPECTF--
Deprecated: Function fgetss() is deprecated in %s on line %d
diff --git a/ext/spl/tests/bug45826.phpt b/ext/spl/tests/bug45826.phpt
index 7993bfaa95..8187b3a320 100644
--- a/ext/spl/tests/bug45826.phpt
+++ b/ext/spl/tests/bug45826.phpt
@@ -31,12 +31,12 @@ var_dump($o2[2][2] === $o2[2]);
echo "#### Extending ArrayObject\n";
unset($o,$x,$s1,$s2,$o1,$o2);
class ArrayObject2 extends ArrayObject {
- public function serialize() {
- return parent::serialize();
+ public function __serialize() {
+ return parent::__serialize();
}
- public function unserialize($s) {
- return parent::unserialize($s);
+ public function __unserialize($s) {
+ return parent::__unserialize($s);
}
}
@@ -50,17 +50,17 @@ var_dump($o[0] === $o[1]);
var_dump($o[2] === $o);
$s1 = serialize($o);
-$s2 = $o->serialize();
+$s2 = $o->__serialize();
var_dump($s1);
var_dump($s2);
-$o1 =unserialize($s1);
+$o1 = unserialize($s1);
var_dump($o1[0] === $o1[1]);
var_dump($o1[2] === $o1);
$o2 = new ArrayObject2();
-$o2->unserialize($s2);
+$o2->__unserialize($s2);
var_dump($o2[0] === $o2[1]);
var_dump($o2[2] !== $o2);
@@ -69,8 +69,8 @@ var_dump($o2[2][2] === $o2[2]);
--EXPECT--
bool(true)
bool(true)
-string(84) "C:11:"ArrayObject":60:{x:i:0;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:4;i:2;r:1;};m:a:0:{}}"
-string(125) "x:i:0;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:3;i:2;C:11:"ArrayObject":45:{x:i:0;a:3:{i:0;r:3;i:1;r:3;i:2;r:5;};m:a:0:{}}};m:a:0:{}"
+string(90) "O:11:"ArrayObject":3:{i:0;i:0;i:1;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:4;i:2;r:1;}i:2;a:0:{}}"
+string(131) "x:i:0;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:3;i:2;O:11:"ArrayObject":3:{i:0;i:0;i:1;a:3:{i:0;r:3;i:1;r:3;i:2;r:5;}i:2;a:0:{}}};m:a:0:{}"
bool(true)
bool(true)
bool(true)
@@ -79,8 +79,28 @@ bool(true)
#### Extending ArrayObject
bool(true)
bool(true)
-string(85) "C:12:"ArrayObject2":60:{x:i:0;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:4;i:2;r:1;};m:a:0:{}}"
-string(126) "x:i:0;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:3;i:2;C:12:"ArrayObject2":45:{x:i:0;a:3:{i:0;r:3;i:1;r:3;i:2;r:5;};m:a:0:{}}};m:a:0:{}"
+string(91) "O:12:"ArrayObject2":3:{i:0;i:0;i:1;a:3:{i:0;O:8:"stdClass":0:{}i:1;r:4;i:2;r:1;}i:2;a:0:{}}"
+array(3) {
+ [0]=>
+ int(0)
+ [1]=>
+ array(3) {
+ [0]=>
+ object(stdClass)#8 (0) {
+ }
+ [1]=>
+ object(stdClass)#8 (0) {
+ }
+ [2]=>
+ object(ArrayObject2)#5 (1) {
+ ["storage":"ArrayObject":private]=>
+ *RECURSION*
+ }
+ }
+ [2]=>
+ array(0) {
+ }
+}
bool(true)
bool(true)
bool(true)
diff --git a/ext/spl/tests/bug47534.phpt b/ext/spl/tests/bug47534.phpt
index d221c23fdb..0d1a5a69ff 100644
--- a/ext/spl/tests/bug47534.phpt
+++ b/ext/spl/tests/bug47534.phpt
@@ -2,11 +2,11 @@
SPL: RecursiveDirectoryIterator bug 47534
--FILE--
<?php
-$it1 = new RecursiveDirectoryIterator(dirname(__FILE__), FileSystemIterator::CURRENT_AS_PATHNAME);
+$it1 = new RecursiveDirectoryIterator(__DIR__, FileSystemIterator::CURRENT_AS_PATHNAME);
$it1->rewind();
echo gettype($it1->current())."\n";
-$it2 = new RecursiveDirectoryIterator(dirname(__FILE__));
+$it2 = new RecursiveDirectoryIterator(__DIR__);
$it2->rewind();
echo gettype($it2->current())."\n";
--EXPECT--
diff --git a/ext/spl/tests/bug49263.phpt b/ext/spl/tests/bug49263.phpt
index a2e2e0b396..4d9e8e1d60 100644
--- a/ext/spl/tests/bug49263.phpt
+++ b/ext/spl/tests/bug49263.phpt
@@ -17,7 +17,7 @@ var_dump(unserialize($ss));
?>
===DONE===
--EXPECTF--
-C:16:"SplObjectStorage":113:{x:i:2;O:8:"stdClass":0:{},a:2:{s:4:"prev";i:2;s:4:"next";O:8:"stdClass":0:{}};r:6;,a:1:{s:4:"prev";r:3;};m:a:0:{}}
+O:16:"SplObjectStorage":2:{i:0;a:4:{i:0;O:8:"stdClass":0:{}i:1;a:2:{s:4:"prev";i:2;s:4:"next";O:8:"stdClass":0:{}}i:2;r:6;i:3;a:1:{s:4:"prev";r:3;}}i:1;a:0:{}}
object(SplObjectStorage)#2 (1) {
["storage":"SplObjectStorage":private]=>
array(2) {
diff --git a/ext/spl/tests/bug53071.phpt b/ext/spl/tests/bug53071.phpt
index ca394f5434..4a2450e201 100644
--- a/ext/spl/tests/bug53071.phpt
+++ b/ext/spl/tests/bug53071.phpt
@@ -23,5 +23,5 @@ echo "Done.\n";
?>
--EXPECT--
-int(4)
+int(3)
Done.
diff --git a/ext/spl/tests/bug61347.phpt b/ext/spl/tests/bug61347.phpt
index f893b24527..410d65b7e9 100644
--- a/ext/spl/tests/bug61347.phpt
+++ b/ext/spl/tests/bug61347.phpt
@@ -22,13 +22,15 @@ var_dump(isset($b[37])); //true
var_dump(isset($b['no_exists'])); //false
var_dump(empty($b['b'])); //true
var_dump(empty($b[37])); //true
---EXPECT--
+--EXPECTF--
bool(false)
bool(false)
bool(false)
bool(false)
bool(true)
bool(true)
+
+Deprecated: array_key_exists(): Using array_key_exists() on objects is deprecated. Use isset() or property_exists() instead in %s on line %d
bool(true)
NULL
bool(true)
diff --git a/ext/spl/tests/bug62978.phpt b/ext/spl/tests/bug62978.phpt
index 5c55507ad9..972bd07ce1 100644
--- a/ext/spl/tests/bug62978.phpt
+++ b/ext/spl/tests/bug62978.phpt
@@ -32,6 +32,8 @@ Notice: Undefined index: epic_magic in %sbug62978.php on line %d
NULL
Notice: Undefined variable: c in %sbug62978.php on line %d
+
+Notice: Trying to access array offset on value of type null in %s on line %d
NULL
Notice: Undefined index: epic_magic in %sbug62978.php on line %d
diff --git a/ext/spl/tests/bug67359.phpt b/ext/spl/tests/bug67359.phpt
index e97a403717..3e8f30cd2b 100644
--- a/ext/spl/tests/bug67359.phpt
+++ b/ext/spl/tests/bug67359.phpt
@@ -4,7 +4,7 @@ Bug #67359 (Segfault in recursiveDirectoryIterator)
<?php
try
{
- $rdi = new recursiveDirectoryIterator(dirname(__FILE__), FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS);
+ $rdi = new recursiveDirectoryIterator(__DIR__, FilesystemIterator::SKIP_DOTS | FilesystemIterator::UNIX_PATHS);
$it = new recursiveIteratorIterator( $rdi );
$it->seek(1);
while( $it->valid())
diff --git a/ext/spl/tests/bug68825.phpt b/ext/spl/tests/bug68825.phpt
index b1ed5fb60f..e662503611 100644
--- a/ext/spl/tests/bug68825.phpt
+++ b/ext/spl/tests/bug68825.phpt
@@ -3,12 +3,16 @@ Bug #68825 (Exception in DirectoryIterator::getLinkTarget())
--FILE--
<?php
$dir = __DIR__ . '/bug68825';
-mkdir($dir);
-symlink(__FILE__, "$dir/foo");
+
+if (!mkdir($dir)) {
+ die('Failed to create temporary directory for testing');
+} else if (!symlink(__FILE__, $dir . '/bug')) {
+ die('Failed to create symbolic link');
+}
$di = new \DirectoryIterator($dir);
foreach ($di as $entry) {
- if ('foo' === $entry->getFilename()) {
+ if ('bug' === $entry->getFilename()) {
var_dump($entry->getLinkTarget());
}
}
@@ -20,6 +24,6 @@ string(%d) "%s%eext%espl%etests%ebug68825.php"
--CLEAN--
<?php
$dir = __DIR__ . '/bug68825';
-unlink("$dir/foo");
+unlink($dir . '/bug');
rmdir($dir);
?>
diff --git a/ext/spl/tests/bug70868.phpt b/ext/spl/tests/bug70868.phpt
index 724576d3bc..fd3bbf43e5 100644
--- a/ext/spl/tests/bug70868.phpt
+++ b/ext/spl/tests/bug70868.phpt
@@ -2,8 +2,6 @@
Bug #70868, with PCRE JIT
--INI--
pcre.jit=1
---SKIPIF--
-<?php if (!extension_loaded("pcre")) die("skip"); ?>
--FILE--
<?php
diff --git a/ext/spl/tests/bug71412.phpt b/ext/spl/tests/bug71412.phpt
index 7db6b08469..7857f27ace 100644
--- a/ext/spl/tests/bug71412.phpt
+++ b/ext/spl/tests/bug71412.phpt
@@ -9,6 +9,6 @@ Method [ <internal:SPL, ctor> public method __construct ] {
- Parameters [2] {
Parameter #0 [ <optional> $array ]
- Parameter #1 [ <optional> $ar_flags ]
+ Parameter #1 [ <optional> $flags ]
}
}
diff --git a/ext/spl/tests/bug73423.phpt b/ext/spl/tests/bug73423.phpt
index 965b63318e..549ceabb8a 100644
--- a/ext/spl/tests/bug73423.phpt
+++ b/ext/spl/tests/bug73423.phpt
@@ -68,15 +68,15 @@ foreach (new \RecursiveIteratorIterator (new fooIterator ($foo)) as $bar) ;
?>
--EXPECTF--
-Fatal error: Uncaught Error: Class 'NotExists' not found in %sbug73423.php(%d) : eval()'d code:1
+Fatal error: Uncaught Error: Class 'NotExists' not found in %s:%d
Stack trace:
-#0 %sbug73423.php(%d): eval()
-#1 %sbug73423.php(%d): fooIterator->__destruct()
+#0 %s(%d): eval()
+#1 %s(%d): fooIterator->__destruct()
#2 {main}
-Next Error: Class 'NotExists' not found in %sbug73423.php(%d) : eval()'d code:1
+Next Error: Class 'NotExists' not found in %s:%d
Stack trace:
-#0 %sbug73423.php(%d): eval()
-#1 %sbug73423.php(%d): fooIterator->__destruct()
+#0 %s(%d): eval()
+#1 %s(%d): fooIterator->__destruct()
#2 {main}
- thrown in %sbug73423.php(%d) : eval()'d code on line 1
+ thrown in %s on line %d
diff --git a/ext/spl/tests/bug74669.phpt b/ext/spl/tests/bug74669.phpt
index 5e4fcd023b..264cd3b97a 100644
--- a/ext/spl/tests/bug74669.phpt
+++ b/ext/spl/tests/bug74669.phpt
@@ -104,7 +104,7 @@ object(SelfArray)#9 (1) {
["foo"]=>
string(3) "bar"
}
-string(62) "C:9:"SelfArray":41:{x:i:16777216;m:a:1:{s:3:"foo";s:3:"bar";}}"
+string(71) "O:9:"SelfArray":3:{i:0;i:16777216;i:1;N;i:2;a:1:{s:3:"foo";s:3:"bar";}}"
object(SelfArray)#9 (1) {
["foo"]=>
string(3) "bar"
diff --git a/ext/spl/tests/bug78409.phpt b/ext/spl/tests/bug78409.phpt
new file mode 100644
index 0000000000..f59015fea7
--- /dev/null
+++ b/ext/spl/tests/bug78409.phpt
@@ -0,0 +1,26 @@
+--TEST--
+Bug #78409: Segfault when creating instance of ArrayIterator without constructor
+--FILE--
+<?php
+
+$a = new ArrayObject;
+$u = [
+ 0,
+ [],
+ [],
+];
+$a->__unserialize($u);
+var_dump($u);
+
+?>
+--EXPECT--
+array(3) {
+ [0]=>
+ int(0)
+ [1]=>
+ array(0) {
+ }
+ [2]=>
+ array(0) {
+ }
+}
diff --git a/ext/spl/tests/bug78436.phpt b/ext/spl/tests/bug78436.phpt
new file mode 100644
index 0000000000..8b978d5a4b
--- /dev/null
+++ b/ext/spl/tests/bug78436.phpt
@@ -0,0 +1,46 @@
+--TEST--
+Bug #78436: Missing addref in SplPriorityQueue EXTR_BOTH mode
+--FILE--
+<?php
+
+$pq = new SplPriorityQueue();
+$pq->insert(new stdClass, 1);
+var_dump($pq);
+var_dump($pq);
+
+?>
+--EXPECT--
+object(SplPriorityQueue)#1 (3) {
+ ["flags":"SplPriorityQueue":private]=>
+ int(1)
+ ["isCorrupted":"SplPriorityQueue":private]=>
+ bool(false)
+ ["heap":"SplPriorityQueue":private]=>
+ array(1) {
+ [0]=>
+ array(2) {
+ ["data"]=>
+ object(stdClass)#2 (0) {
+ }
+ ["priority"]=>
+ int(1)
+ }
+ }
+}
+object(SplPriorityQueue)#1 (3) {
+ ["flags":"SplPriorityQueue":private]=>
+ int(1)
+ ["isCorrupted":"SplPriorityQueue":private]=>
+ bool(false)
+ ["heap":"SplPriorityQueue":private]=>
+ array(1) {
+ [0]=>
+ array(2) {
+ ["data"]=>
+ object(stdClass)#2 (0) {
+ }
+ ["priority"]=>
+ int(1)
+ }
+ }
+}
diff --git a/ext/spl/tests/bug78456.phpt b/ext/spl/tests/bug78456.phpt
new file mode 100644
index 0000000000..e7cf50f366
--- /dev/null
+++ b/ext/spl/tests/bug78456.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Bug #78456: Segfault when serializing SplDoublyLinkedList
+--FILE--
+<?php
+
+$dllist = new SplDoublyLinkedList();
+$dllist->push(new stdClass);
+var_dump($s = serialize($dllist));
+var_dump(unserialize($s));
+
+?>
+--EXPECT--
+string(82) "O:19:"SplDoublyLinkedList":3:{i:0;i:0;i:1;a:1:{i:0;O:8:"stdClass":0:{}}i:2;a:0:{}}"
+object(SplDoublyLinkedList)#3 (2) {
+ ["flags":"SplDoublyLinkedList":private]=>
+ int(0)
+ ["dllist":"SplDoublyLinkedList":private]=>
+ array(1) {
+ [0]=>
+ object(stdClass)#4 (0) {
+ }
+ }
+}
diff --git a/ext/spl/tests/class_implements_variation2.phpt b/ext/spl/tests/class_implements_variation2.phpt
deleted file mode 100644
index d63669fbec..0000000000
--- a/ext/spl/tests/class_implements_variation2.phpt
+++ /dev/null
@@ -1,259 +0,0 @@
---TEST--
-SPL: Test class_implements() function : variation
---FILE--
-<?php
-/* Prototype : array class_implements(mixed what [, bool autoload ])
- * Description: Return all classes and interfaces implemented by SPL
- * Source code: ext/spl/php_spl.c
- * Alias to functions:
- */
-
-echo "*** Testing class_implements() : variation ***\n";
-
-
-// Define error handler
-function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
- if (error_reporting() != 0) {
- // report non-silenced errors
- echo "Error: $err_no - $err_msg, $filename($linenum)\n";
- }
-}
-set_error_handler('test_error_handler');
-
-// Initialise function arguments not being substituted (if any)
-$class = 'Iterator';
-
-//resource
-$res = fopen(__FILE__,'r');
-
-//get an unset variable
-$unset_var = 10;
-unset ($unset_var);
-
-// define some classes
-class classWithToString
-{
- public function __toString() {
- return "Class A object";
- }
-}
-
-class classWithoutToString
-{
-}
-
-// heredoc string
-$heredoc = <<<EOT
-hello world
-EOT;
-
-// add arrays
-$index_array = array (1, 2, 3);
-$assoc_array = array ('one' => 1, 'two' => 2);
-
-//array of values to iterate over
-$inputs = array(
-
- // int data
- 'int 0' => 0,
- 'int 1' => 1,
- 'int 12345' => 12345,
- 'int -12345' => -2345,
-
- // float data
- 'float 10.5' => 10.5,
- 'float -10.5' => -10.5,
- 'float 12.3456789000e10' => 12.3456789000e10,
- 'float -12.3456789000e10' => -12.3456789000e10,
- 'float .5' => .5,
-
- // array data
- 'empty array' => array(),
- 'int indexed array' => $index_array,
- 'associative array' => $assoc_array,
- 'nested arrays' => array('foo', $index_array, $assoc_array),
-
- // null data
- 'uppercase NULL' => NULL,
- 'lowercase null' => null,
-
- // boolean data
- 'lowercase true' => true,
- 'lowercase false' =>false,
- 'uppercase TRUE' =>TRUE,
- 'uppercase FALSE' =>FALSE,
-
- // empty data
- 'empty string DQ' => "",
- 'empty string SQ' => '',
-
- // object data
- 'instance of classWithToString' => new classWithToString(),
- 'instance of classWithoutToString' => new classWithoutToString(),
-
- // undefined data
- 'undefined var' => @$undefined_var,
-
- // unset data
- 'unset var' => @$unset_var,
-
- //resource
- 'resource' => $res,
-);
-
-// loop through each element of the array for pattern
-
-foreach($inputs as $key =>$value) {
- echo "\n--$key--\n";
- var_dump( class_implements($class, $value) );
-};
-
-fclose($res);
-
-?>
-===DONE===
---EXPECTF--
-*** Testing class_implements() : variation ***
-
---int 0--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---int 1--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---int 12345--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---int -12345--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---float 10.5--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---float -10.5--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---float 12.3456789000e10--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---float -12.3456789000e10--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---float .5--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---empty array--
-Error: 2 - class_implements() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---int indexed array--
-Error: 2 - class_implements() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---associative array--
-Error: 2 - class_implements() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---nested arrays--
-Error: 2 - class_implements() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---uppercase NULL--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---lowercase null--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---lowercase true--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---lowercase false--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---uppercase TRUE--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---uppercase FALSE--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---empty string DQ--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---empty string SQ--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---instance of classWithToString--
-Error: 2 - class_implements() expects parameter 2 to be bool, object given, %s(%d)
-bool(false)
-
---instance of classWithoutToString--
-Error: 2 - class_implements() expects parameter 2 to be bool, object given, %s(%d)
-bool(false)
-
---undefined var--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---unset var--
-array(1) {
- ["Traversable"]=>
- string(11) "Traversable"
-}
-
---resource--
-Error: 2 - class_implements() expects parameter 2 to be bool, resource given, %s(%d)
-bool(false)
-===DONE===
diff --git a/ext/spl/tests/class_uses_variation2.phpt b/ext/spl/tests/class_uses_variation2.phpt
deleted file mode 100644
index 6458bd178c..0000000000
--- a/ext/spl/tests/class_uses_variation2.phpt
+++ /dev/null
@@ -1,261 +0,0 @@
---TEST--
-SPL: Test class_uses() function : variation
---FILE--
-<?php
-/* Prototype : array class_uses(mixed what [, bool autoload ])
- * Description: Return all traits used by a class
- * Source code: ext/spl/php_spl.c
- * Alias to functions:
- */
-
-echo "*** Testing class_uses() : variation ***\n";
-
-trait foo {}
-class fooUser { use foo; }
-
-// Define error handler
-function test_error_handler($err_no, $err_msg, $filename, $linenum, $vars) {
- if (error_reporting() != 0) {
- // report non-silenced errors
- echo "Error: $err_no - $err_msg, $filename($linenum)\n";
- }
-}
-set_error_handler('test_error_handler');
-
-// Initialise function arguments not being substituted (if any)
-$class = 'fooUser';
-
-//resource
-$res = fopen(__FILE__,'r');
-
-//get an unset variable
-$unset_var = 10;
-unset ($unset_var);
-
-// define some classes
-class classWithToString
-{
- public function __toString() {
- return "Class A object";
- }
-}
-
-class classWithoutToString
-{
-}
-
-// heredoc string
-$heredoc = <<<EOT
-hello world
-EOT;
-
-// add arrays
-$index_array = array (1, 2, 3);
-$assoc_array = array ('one' => 1, 'two' => 2);
-
-//array of values to iterate over
-$inputs = array(
-
- // int data
- 'int 0' => 0,
- 'int 1' => 1,
- 'int 12345' => 12345,
- 'int -12345' => -2345,
-
- // float data
- 'float 10.5' => 10.5,
- 'float -10.5' => -10.5,
- 'float 12.3456789000e10' => 12.3456789000e10,
- 'float -12.3456789000e10' => -12.3456789000e10,
- 'float .5' => .5,
-
- // array data
- 'empty array' => array(),
- 'int indexed array' => $index_array,
- 'associative array' => $assoc_array,
- 'nested arrays' => array('foo', $index_array, $assoc_array),
-
- // null data
- 'uppercase NULL' => NULL,
- 'lowercase null' => null,
-
- // boolean data
- 'lowercase true' => true,
- 'lowercase false' =>false,
- 'uppercase TRUE' =>TRUE,
- 'uppercase FALSE' =>FALSE,
-
- // empty data
- 'empty string DQ' => "",
- 'empty string SQ' => '',
-
- // object data
- 'instance of classWithToString' => new classWithToString(),
- 'instance of classWithoutToString' => new classWithoutToString(),
-
- // undefined data
- 'undefined var' => @$undefined_var,
-
- // unset data
- 'unset var' => @$unset_var,
-
- //resource
- 'resource' => $res,
-);
-
-// loop through each element of the array for pattern
-
-foreach($inputs as $key =>$value) {
- echo "\n--$key--\n";
- var_dump( class_uses($class, $value) );
-};
-
-fclose($res);
-
-?>
-===DONE===
---EXPECTF--
-*** Testing class_uses() : variation ***
-
---int 0--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---int 1--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---int 12345--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---int -12345--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---float 10.5--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---float -10.5--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---float 12.3456789000e10--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---float -12.3456789000e10--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---float .5--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---empty array--
-Error: 2 - class_uses() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---int indexed array--
-Error: 2 - class_uses() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---associative array--
-Error: 2 - class_uses() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---nested arrays--
-Error: 2 - class_uses() expects parameter 2 to be bool, array given, %s(%d)
-bool(false)
-
---uppercase NULL--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---lowercase null--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---lowercase true--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---lowercase false--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---uppercase TRUE--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---uppercase FALSE--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---empty string DQ--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---empty string SQ--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---instance of classWithToString--
-Error: 2 - class_uses() expects parameter 2 to be bool, object given, %s(%d)
-bool(false)
-
---instance of classWithoutToString--
-Error: 2 - class_uses() expects parameter 2 to be bool, object given, %s(%d)
-bool(false)
-
---undefined var--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---unset var--
-array(1) {
- ["foo"]=>
- string(3) "foo"
-}
-
---resource--
-Error: 2 - class_uses() expects parameter 2 to be bool, resource given, %s(%d)
-bool(false)
-===DONE===
diff --git a/ext/spl/tests/countable_class_basic1.phpt b/ext/spl/tests/countable_class_basic1.phpt
index 3108cb1818..ede42e960f 100644
--- a/ext/spl/tests/countable_class_basic1.phpt
+++ b/ext/spl/tests/countable_class_basic1.phpt
@@ -2,7 +2,7 @@
SPL: Test shape of interface Countable.
--FILE--
<?php
-ReflectionClass::export('Countable');
+echo new ReflectionClass('Countable');
?>
--EXPECTF--
Interface [ <internal%s> interface Countable ] {
diff --git a/ext/spl/tests/dit_005.phpt b/ext/spl/tests/dit_005.phpt
index 9278a115a3..942a58d4ae 100644
--- a/ext/spl/tests/dit_005.phpt
+++ b/ext/spl/tests/dit_005.phpt
@@ -2,7 +2,8 @@
SPL: FilesystemIterator and clone
--FILE--
<?php
-$a = new FileSystemIterator(__DIR__);
+// Let's hope nobody writes into this directory while testing...
+$a = new FileSystemIterator(__DIR__ . '/..');
$b = clone $a;
var_dump((string)$b == (string)$a);
var_dump($a->key() == $b->key());
diff --git a/ext/spl/examples/dualiterator.inc b/ext/spl/tests/dualiterator.inc
index eeb8ae869c..eeb8ae869c 100644
--- a/ext/spl/examples/dualiterator.inc
+++ b/ext/spl/tests/dualiterator.inc
diff --git a/ext/spl/examples/tests/dualiterator_001.phpt b/ext/spl/tests/dualiterator_001.phpt
index eb92347d51..934f28abee 100644
--- a/ext/spl/examples/tests/dualiterator_001.phpt
+++ b/ext/spl/tests/dualiterator_001.phpt
@@ -5,7 +5,7 @@ SPL: DualIterator
function spl_examples_autoload($classname)
{
- include(dirname(__FILE__) . '/../' . strtolower($classname) . '.inc');
+ include(__DIR__ . '/' . strtolower($classname) . '.inc');
}
spl_autoload_register('spl_examples_autoload');
diff --git a/ext/spl/tests/fileobject_001.phpt b/ext/spl/tests/fileobject_001.phpt
index 61f688d79f..4059310bba 100644
--- a/ext/spl/tests/fileobject_001.phpt
+++ b/ext/spl/tests/fileobject_001.phpt
@@ -3,7 +3,7 @@ SPL: SplFileObject::seek'ing
--FILE--
<?php
-$o = new SplFileObject(dirname(__FILE__) . '/fileobject_001a.txt');
+$o = new SplFileObject(__DIR__ . '/fileobject_001a.txt');
var_dump($o->key());
var_dump($o->current());
@@ -31,7 +31,7 @@ foreach($o as $n => $l)
}
echo "===B===\n";
-$o = new SplFileObject(dirname(__FILE__) . '/fileobject_001b.txt');
+$o = new SplFileObject(__DIR__ . '/fileobject_001b.txt');
$o->setFlags(SplFileObject::DROP_NEW_LINE);
foreach($o as $n => $l)
{
@@ -40,12 +40,12 @@ foreach($o as $n => $l)
?>
===DONE===
---EXPECT--
+--EXPECTF--
int(0)
-string(2) "0
+string(%d) "0
"
int(0)
-string(2) "0
+string(%d) "0
"
int(0)
int(1)
diff --git a/ext/spl/tests/fileobject_001a.txt b/ext/spl/tests/fileobject_001a.txt
index e8371f0060..e8371f0060 100755..100644
--- a/ext/spl/tests/fileobject_001a.txt
+++ b/ext/spl/tests/fileobject_001a.txt
diff --git a/ext/spl/tests/fileobject_001b.txt b/ext/spl/tests/fileobject_001b.txt
index 0c4a8b5cd3..0c4a8b5cd3 100755..100644
--- a/ext/spl/tests/fileobject_001b.txt
+++ b/ext/spl/tests/fileobject_001b.txt
diff --git a/ext/spl/tests/fileobject_002.phpt b/ext/spl/tests/fileobject_002.phpt
index 8031e98fdc..2f43949966 100644
--- a/ext/spl/tests/fileobject_002.phpt
+++ b/ext/spl/tests/fileobject_002.phpt
@@ -7,11 +7,15 @@ function test($name)
{
echo "===$name===\n";
- $o = new SplFileObject(dirname(__FILE__) . '/' . $name);
+ $o = new SplFileObject(__DIR__ . '/' . $name);
var_dump($o->key());
while(($c = $o->fgetc()) !== false)
{
+ // Kinda ugly but works around new lines mess
+ if ($c === "\r") {
+ continue;
+ }
var_dump($o->key(), $c, $o->eof());
}
echo "===EOF?===\n";
diff --git a/ext/spl/tests/fileobject_003.phpt b/ext/spl/tests/fileobject_003.phpt
index 822e21b9fa..c3452bc93f 100644
--- a/ext/spl/tests/fileobject_003.phpt
+++ b/ext/spl/tests/fileobject_003.phpt
@@ -41,9 +41,9 @@ function test($name, $lc, $lp)
}
}
-test(dirname(__FILE__) . '/' . 'fileobject_001a.txt', 't', substr(dirname(__FILE__),-1));
-test(dirname(__FILE__) . '/', substr(dirname(__FILE__),-1), 'l');
-test(dirname(__FILE__), substr(dirname(__FILE__),-1), 'l');
+test(__DIR__ . '/' . 'fileobject_001a.txt', 't', substr(__DIR__,-1));
+test(__DIR__ . '/', substr(__DIR__,-1), 'l');
+test(__DIR__, substr(__DIR__,-1), 'l');
?>
===DONE===
diff --git a/ext/spl/tests/fileobject_004.phpt b/ext/spl/tests/fileobject_004.phpt
index 02e6725853..fad87298ca 100644
--- a/ext/spl/tests/fileobject_004.phpt
+++ b/ext/spl/tests/fileobject_004.phpt
@@ -5,7 +5,7 @@ SPL: SplFileObject realpath and include_path
set_include_path('tests');
-chdir(dirname(dirname(__FILE__))); // ext/spl
+chdir(dirname(__DIR__)); // ext/spl
$fo = new SplFileObject('fileobject_004.phpt', 'r', true);
diff --git a/ext/spl/tests/fileobject_005.phpt b/ext/spl/tests/fileobject_005.phpt
index 7b012e7710..41a04dd118 100644
--- a/ext/spl/tests/fileobject_005.phpt
+++ b/ext/spl/tests/fileobject_005.phpt
@@ -6,9 +6,9 @@ Mark Ammann
--FILE--
<?php
-set_include_path(dirname(dirname(__FILE__)));
+set_include_path(dirname(__DIR__));
-$path = dirname(__FILE__).DIRECTORY_SEPARATOR.'fileobject_005.txt';
+$path = __DIR__.DIRECTORY_SEPARATOR.'fileobject_005.txt';
touch($path);
$fo = new SplFileObject('tests'.DIRECTORY_SEPARATOR.'fileobject_005.txt', 'w+', true);
@@ -28,7 +28,7 @@ var_dump($fo->ftruncate());
==DONE==
--CLEAN--
<?php
-$path = dirname(__FILE__).DIRECTORY_SEPARATOR.'fileobject_005.txt';
+$path = __DIR__.DIRECTORY_SEPARATOR.'fileobject_005.txt';
unlink($path);
?>
--EXPECTF--
diff --git a/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt b/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt
deleted file mode 100644
index 3c0c9eebd5..0000000000
--- a/ext/spl/tests/fileobject_getmaxlinelen_error001.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SPL: SplFileObject::getMaxLineLen error 001
---CREDITS--
-Erwin Poeze <erwin.poeze at gmail.com>
---INI--
-include_path=.
---FILE--
-<?php
-$s = new SplFileObject( __FILE__ );
-$s->getMaxLineLen('string');
-
-?>
---EXPECTF--
-Warning: SplFileObject::getMaxLineLen() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt
deleted file mode 100644
index dad59fca5f..0000000000
--- a/ext/spl/tests/fileobject_setmaxlinelen_error002.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-SPL: SplFileObject::setMaxLineLen error 002
---CREDITS--
-Erwin Poeze <erwin.poeze at gmail.com>
---FILE--
-<?php
-$s = new SplFileObject( __FILE__ );
-$s->setMaxLineLen();
-
-?>
---EXPECTF--
-Warning: SplFileObject::setMaxLineLen() expects exactly 1 parameter, 0 given in %s on line %d
diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt
deleted file mode 100644
index 14387998fb..0000000000
--- a/ext/spl/tests/fileobject_setmaxlinelen_error003.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-SPL: SplFileObject::setMaxLineLen error 003
---CREDITS--
-Erwin Poeze <erwin.poeze at gmail.com>
---FILE--
-<?php
-$s = new SplFileObject( __FILE__ );
-$s->setMaxLineLen('string');
-
-?>
---EXPECTF--
-Warning: SplFileObject::setMaxLineLen() expects parameter 1 to be int, string given in %s on line %d
diff --git a/ext/spl/tests/heap_isempty_variation_001.phpt b/ext/spl/tests/heap_isempty_variation_001.phpt
deleted file mode 100644
index dac470fccf..0000000000
--- a/ext/spl/tests/heap_isempty_variation_001.phpt
+++ /dev/null
@@ -1,16 +0,0 @@
---TEST--
-SPL: SplHeap: isEmpty argument variation.
---FILE--
-<?php
-class SplHeap2 extends SplHeap{
-
- public function compare() {
- return -parent::compare();
- }
-}
-
-$h = new SplHeap2;
-$h->isEmpty(1);
-?>
---EXPECTF--
-Warning: SplHeap::isEmpty() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/heap_top_variation_001.phpt b/ext/spl/tests/heap_top_variation_001.phpt
deleted file mode 100644
index 9953cf9ade..0000000000
--- a/ext/spl/tests/heap_top_variation_001.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SPL: SplHeap top, illegal number of args
---CREDITS--
-Mark Schaschke (mark@fractalturtle.com)
-TestFest London May 2009
---FILE--
-<?php
-$h = new SplMinHeap();
-$h->insert(5);
-// top doesn't take any args, lets see what happens if we give it one
-$h->top('bogus');
-?>
---EXPECTF--
-Warning: SplHeap::top() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/iterator_035.phpt b/ext/spl/tests/iterator_035.phpt
index e6d68fbea6..0688635450 100644
--- a/ext/spl/tests/iterator_035.phpt
+++ b/ext/spl/tests/iterator_035.phpt
@@ -14,7 +14,7 @@ echo "Done\n";
--EXPECTF--
Notice: Indirect modification of overloaded element of ArrayIterator has no effect in %s on line %d
-Fatal error: Uncaught Error: Cannot assign by reference to overloaded object in %s:%d
+Fatal error: Uncaught Error: Cannot assign by reference to an array dimension of an object in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d
diff --git a/ext/spl/tests/iterator_036.phpt b/ext/spl/tests/iterator_036.phpt
index 74d393b677..07a1f79134 100644
--- a/ext/spl/tests/iterator_036.phpt
+++ b/ext/spl/tests/iterator_036.phpt
@@ -18,4 +18,9 @@ test(new CachingIterator($ar, 0));
?>
===DONE===
--EXPECTF--
-Fatal error: Method CachingIterator::__toString() must not throw an exception, caught BadMethodCallException: CachingIterator does not fetch string value (see CachingIterator::__construct) in %siterator_036.php on line %d
+Fatal error: Uncaught BadMethodCallException: CachingIterator does not fetch string value (see CachingIterator::__construct) in %s:%d
+Stack trace:
+#0 %s(%d): CachingIterator->__toString()
+#1 %s(%d): test(Object(CachingIterator))
+#2 {main}
+ thrown in %s on line %d
diff --git a/ext/spl/tests/limititerator_seek.phpt b/ext/spl/tests/limititerator_seek.phpt
deleted file mode 100644
index 3336cd0a39..0000000000
--- a/ext/spl/tests/limititerator_seek.phpt
+++ /dev/null
@@ -1,16 +0,0 @@
---TEST--
-SPL: LimitIterator seek() arguments
---CREDITS--
-Roshan Abraham (roshanabrahams@gmail.com)
-TestFest London May 2009
---FILE--
-<?php
-
-$a = array(1,2,3);
-$lt = new LimitIterator(new ArrayIterator($a));
-
-$lt->seek(1,1); // Should throw a warning as seek expects only 1 argument
-
-?>
---EXPECTF--
-Warning: LimitIterator::seek() expects exactly 1 parameter, 2 given in %s on line %d
diff --git a/ext/spl/tests/observer_010.phpt b/ext/spl/tests/observer_010.phpt
index 5cb9b799ee..a62018958e 100644
--- a/ext/spl/tests/observer_010.phpt
+++ b/ext/spl/tests/observer_010.phpt
@@ -2,8 +2,7 @@
SPL: SplObjectStorage null coalescing operator memory leak
--FILE--
<?php
-// In maintainer zts mode, this should no longer
-// detect memory leaks for the objects
+// In zts mode, this should no longer detect memory leaks for the objects
$a = new stdClass();
$b = new stdClass();
$map = new SplObjectStorage();
diff --git a/ext/spl/tests/pqueue_compare_error.phpt b/ext/spl/tests/pqueue_compare_error.phpt
deleted file mode 100644
index 99b47bb437..0000000000
--- a/ext/spl/tests/pqueue_compare_error.phpt
+++ /dev/null
@@ -1,18 +0,0 @@
---TEST--
-SPL: Priority queue compare, illegal number of args
---CREDITS--
-Mark Schaschke (mark@fractalturtle.com)
-TestFest London May 2009
---FILE--
-<?php
-$h = new SplPriorityQueue();
-$h->compare();
-$h->compare(1);
-$h->compare(1, 2, 3);
-?>
---EXPECTF--
-Warning: SplPriorityQueue::compare() expects exactly 2 parameters, 0 given in %s
-
-Warning: SplPriorityQueue::compare() expects exactly 2 parameters, 1 given in %s
-
-Warning: SplPriorityQueue::compare() expects exactly 2 parameters, 3 given in %s
diff --git a/ext/spl/tests/recursive_tree_iterator_007.phpt b/ext/spl/tests/recursive_tree_iterator_007.phpt
index 7374a066fa..a017254df0 100644
--- a/ext/spl/tests/recursive_tree_iterator_007.phpt
+++ b/ext/spl/tests/recursive_tree_iterator_007.phpt
@@ -22,12 +22,12 @@ try {
foreach(new RecursiveTreeIterator($it) as $k => $v) {
echo "[$k] => $v\n";
}
-} catch (UnexpectedValueException $e) {
- echo "UnexpectedValueException thrown\n";
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
}
?>
===DONE===
--EXPECT--
-UnexpectedValueException thrown
+Object of class stdClass could not be converted to string
===DONE===
diff --git a/ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt b/ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt
deleted file mode 100644
index 7076ad9896..0000000000
--- a/ext/spl/tests/recursive_tree_iterator_setprefixpart.phpt
+++ /dev/null
@@ -1,32 +0,0 @@
---TEST--
-SPL: RecursiveTreeIterator::setPrefixPart() Test arguments
---CREDITS--
-Roshan Abraham (roshanabrahams@gmail.com)
-TestFest London May 2009
---FILE--
-<?php
-
-$arr = array(
- "a" => array("b")
-);
-
-$it = new RecursiveArrayIterator($arr);
-$it = new RecursiveTreeIterator($it);
-
-$it->setPrefixPart(1); // Should throw a warning as setPrefixPart expects 2 arguments
-
-$a = new stdClass();
-$it->setPrefixPart($a, 1); // Should throw a warning as setPrefixPart expects argument 1 to be long integer
-
-$it->setPrefixPart(1, $a); // Should throw a warning as setPrefixPart expects argument 2 to be a string
-
-
-?>
-===DONE===
---EXPECTF--
-Warning: RecursiveTreeIterator::setPrefixPart() expects exactly 2 parameters, 1 given in %s on line %d
-
-Warning: RecursiveTreeIterator::setPrefixPart() expects parameter 1 to be int, object given in %s on line %d
-
-Warning: RecursiveTreeIterator::setPrefixPart() expects parameter 2 to be string, object given in %s on line %d
-===DONE===
diff --git a/ext/spl/examples/recursivecomparedualiterator.inc b/ext/spl/tests/recursivecomparedualiterator.inc
index 5b63e9f0b3..5b63e9f0b3 100644
--- a/ext/spl/examples/recursivecomparedualiterator.inc
+++ b/ext/spl/tests/recursivecomparedualiterator.inc
diff --git a/ext/spl/examples/recursivedualiterator.inc b/ext/spl/tests/recursivedualiterator.inc
index a56984e083..a56984e083 100644
--- a/ext/spl/examples/recursivedualiterator.inc
+++ b/ext/spl/tests/recursivedualiterator.inc
diff --git a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt b/ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt
deleted file mode 100644
index 068ace9d8c..0000000000
--- a/ext/spl/tests/recursiveiteratoriterator_getsubiterator_error.phpt
+++ /dev/null
@@ -1,14 +0,0 @@
---TEST--
-SPL: RecursiveIteratorIterator::getSubIterator() expects at most 1 parameter
---CREDITS--
-Matt Raines matt@raines.me.uk
-#testfest London 2009-05-09
---FILE--
-<?php
-$iterator = new RecursiveIteratorIterator(new RecursiveArrayIterator(array()));
-$iterator->getSubIterator();
-$iterator->getSubIterator(0);
-$iterator->getSubIterator(0, 0);
-?>
---EXPECTF--
-Warning: RecursiveIteratorIterator::getSubIterator() expects at most 1 parameter, 2 given in %s on line 5
diff --git a/ext/spl/tests/regexiterator_setflags_exception.phpt b/ext/spl/tests/regexiterator_setflags_exception.phpt
deleted file mode 100644
index 7cf771db6f..0000000000
--- a/ext/spl/tests/regexiterator_setflags_exception.phpt
+++ /dev/null
@@ -1,35 +0,0 @@
---TEST--
-SPL: RegexIterator::setFlags() exceptions test
---CREDITS--
-Lance Kesson jac_kesson@hotmail.com
-#testfest London 2009-05-09
---FILE--
-<?php
-
-class myIterator implements Iterator {
-
-function current (){}
-function key ( ){}
-function next ( ){}
-function rewind ( ){}
-function valid ( ){}
-
-
-}
-
-class TestRegexIterator extends RegexIterator{}
-
-$rege = '/^a/';
-
-
-$r = new TestRegexIterator(new myIterator, $rege);
-
-try{
- $r->setFlags();
-}catch (Exception $e) {
- echo $e->getMessage();
-}
-
-?>
---EXPECTF--
-Warning: RegexIterator::setFlags() expects exactly 1 parameter, 0 given in %s
diff --git a/ext/spl/tests/regexiterator_setpregflags_exception.phpt b/ext/spl/tests/regexiterator_setpregflags_exception.phpt
deleted file mode 100644
index 5750e72af1..0000000000
--- a/ext/spl/tests/regexiterator_setpregflags_exception.phpt
+++ /dev/null
@@ -1,36 +0,0 @@
---TEST--
-SPL: RegexIterator::getPregFlags() exception test
---CREDITS--
-Lance Kesson jac_kesson@hotmail.com
-#testfest London 2009-05-09
---FILE--
-<?php
-
-class myIterator implements Iterator {
-
-function current (){}
-function key ( ){}
-function next ( ){}
-function rewind ( ){}
-function valid ( ){}
-
-
-}
-
-class TestRegexIterator extends RegexIterator{}
-
-$rege = '/^a/';
-
-
-$r = new TestRegexIterator(new myIterator, $rege);
-
-
-try{
- $r->setPregFlags();
-}catch (Exception $e) {
- echo $e->getMessage();
-}
-
-?>
---EXPECTF--
-Warning: RegexIterator::setPregFlags() expects exactly 1 parameter, 0 given in %s
diff --git a/ext/spl/tests/splDoublyLinkedList_shift_noParams.phpt b/ext/spl/tests/splDoublyLinkedList_shift_noParams.phpt
deleted file mode 100644
index cd4ea5b033..0000000000
--- a/ext/spl/tests/splDoublyLinkedList_shift_noParams.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-Checks that the shift() method of DoublyLinkedList does not accept args.
---CREDITS--
-PHPNW Test Fest 2009 - Rick Ogden
---FILE--
-<?php
-$ll = new SplDoublyLinkedList();
-$ll->push(1);
-$ll->push(2);
-
-var_dump($ll->shift(1));
-?>
---EXPECTF--
-Warning: SplDoublyLinkedList::shift() expects exactly 0 parameters, 1 given in %s on line %d
-NULL
diff --git a/ext/spl/tests/spl_005.phpt b/ext/spl/tests/spl_005.phpt
deleted file mode 100644
index cb36df18cf..0000000000
--- a/ext/spl/tests/spl_005.phpt
+++ /dev/null
@@ -1,21 +0,0 @@
---TEST--
-SPL: spl_object_hash()
---FILE--
-<?php
-
-var_dump(spl_object_hash(new stdClass));
-var_dump(spl_object_hash(42));
-var_dump(spl_object_hash());
-
-?>
-===DONE===
-<?php exit(0); ?>
---EXPECTF--
-string(32) "%s"
-
-Warning: spl_object_hash() expects parameter 1 to be object, int given in %sspl_005.php on line %d
-NULL
-
-Warning: spl_object_hash() expects exactly 1 parameter, 0 given in %sspl_005.php on line %d
-NULL
-===DONE===
diff --git a/ext/spl/tests/spl_autoload_007.phpt b/ext/spl/tests/spl_autoload_007.phpt
index 1a81f191c7..3233120790 100644
--- a/ext/spl/tests/spl_autoload_007.phpt
+++ b/ext/spl/tests/spl_autoload_007.phpt
@@ -116,7 +116,7 @@ array(2) {
[1]=>
string(8) "noAccess"
}
-Passed array does not specify a callable method (cannot access protected method MyAutoLoader::noAccess())
+Passed array does not specify a callable static method (cannot access protected method MyAutoLoader::noAccess())
array(2) {
[0]=>
diff --git a/ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt b/ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt
deleted file mode 100644
index 126586bcc7..0000000000
--- a/ext/spl/tests/spl_cachingiterator_setFlags_basic.phpt
+++ /dev/null
@@ -1,16 +0,0 @@
---TEST--
-SPL: SplCachingIterator, Test method to set flags for caching iterator
---CREDITS--
-Chris Scott chris.scott@nstein.com
-#testfest London 2009-05-09
---FILE--
-<?php
-
-$ai = new ArrayIterator(array('foo', 'bar'));
-
-$ci = new CachingIterator($ai);
-$ci->setFlags(); //expects arg
-
-?>
---EXPECTF--
-Warning: CachingIterator::setFlags() expects exactly 1 parameter, %s
diff --git a/ext/spl/tests/spl_heap_count_error.phpt b/ext/spl/tests/spl_heap_count_error.phpt
deleted file mode 100644
index 6bed4cfa60..0000000000
--- a/ext/spl/tests/spl_heap_count_error.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-SPL: Priority queue count, illegal number of args
---CREDITS--
-Mark Schaschke (mark@fractalturtle.com)
-TestFest London May 2009
---FILE--
-<?php
-$h = new SplPriorityQueue();
-$h->count(1);
-?>
---EXPECTF--
-Warning: SplPriorityQueue::count() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/spl_heap_extract_parameter_error.phpt b/ext/spl/tests/spl_heap_extract_parameter_error.phpt
deleted file mode 100644
index aecd03dfa1..0000000000
--- a/ext/spl/tests/spl_heap_extract_parameter_error.phpt
+++ /dev/null
@@ -1,27 +0,0 @@
---TEST--
-SPL: Heap and extract with parameter
---CREDITS--
-Sean Burlington www.practicalweb.co.uk
-TestFest London May 2009
---FILE--
-<?php
-
-class TestHeap extends SplHeap {
-
- function compare() {
- print "This shouldn't be printed";
- }
-}
-
-$testHeap = new TestHeap();
-
-
-
-var_dump($testHeap->extract('test'));
-
-?>
-===DONE===
---EXPECTF--
-Warning: SplHeap::extract() expects exactly 0 parameters, 1 given in %s on line 14
-NULL
-===DONE===
diff --git a/ext/spl/tests/spl_heap_insert_basic.phpt b/ext/spl/tests/spl_heap_insert_basic.phpt
deleted file mode 100644
index 76a34b292b..0000000000
--- a/ext/spl/tests/spl_heap_insert_basic.phpt
+++ /dev/null
@@ -1,20 +0,0 @@
---TEST--
-SPL: SplHeap, Test method to insert into heap
---CREDITS--
-Chris Scott chris.scott@nstein.com
-#testfest London 2009-05-09
---FILE--
-<?php
-class MyHeap extends SplHeap
-{
- public function compare($a, $b)
- {
- return $a < $b;
- }
-}
-
-$heap = new MyHeap();
-$heap->insert(1,2);
-?>
---EXPECTF--
-Warning: SplHeap::insert() expects exactly 1 parameter, %s
diff --git a/ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt b/ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt
deleted file mode 100644
index 126d394f29..0000000000
--- a/ext/spl/tests/spl_heap_recoverfromcorruption_arguments.phpt
+++ /dev/null
@@ -1,13 +0,0 @@
---TEST--
-SPL: SplHeap check no arguments to be accepted on recoverFromCorruption
---CREDITS--
-Rohan Abraham (rohanabrahams@gmail.com)
-TestFest London May 2009
---FILE--
-<?php
- $h = new SplMaxHeap();
- //Line below should throw a warning as no args are expected
- $h->recoverFromCorruption("no args");
-?>
---EXPECTF--
-Warning: SplHeap::recoverFromCorruption() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/spl_iterator_to_array_basic.phpt b/ext/spl/tests/spl_iterator_to_array_basic.phpt
deleted file mode 100644
index 68cb8792a9..0000000000
--- a/ext/spl/tests/spl_iterator_to_array_basic.phpt
+++ /dev/null
@@ -1,13 +0,0 @@
---TEST--
-SPL: iterator_to_array, Test function to convert iterator to array
---CREDITS--
-Chris Scott chris.scott@nstein.com
-#testfest London 2009-05-09
---FILE--
-<?php
-
-iterator_to_array();//requires iterator as arg
-
-?>
---EXPECTF--
-Warning: iterator_to_array() expects at least 1 parameter, %s
diff --git a/ext/spl/tests/spl_maxheap_compare_basic.phpt b/ext/spl/tests/spl_maxheap_compare_basic.phpt
deleted file mode 100644
index 3705b3fd0b..0000000000
--- a/ext/spl/tests/spl_maxheap_compare_basic.phpt
+++ /dev/null
@@ -1,22 +0,0 @@
---TEST--
-SPL: SplMaxHeap, Test method to comare elements
---CREDITS--
-Chris Scott chris.scott@nstein.com
-#testfest London 2009-05-09
---FILE--
-<?php
-
-class MyHeap extends SplMaxHeap
-{
- public function testCompare()
- {
- return parent::compare(1);
- }
-}
-
-$heap = new MyHeap();
-$heap->testCompare();
-
-?>
---EXPECTF--
-Warning: SplMaxHeap::compare() expects exactly 2 parameters, %s
diff --git a/ext/spl/tests/spl_minheap_compare_error.phpt b/ext/spl/tests/spl_minheap_compare_error.phpt
deleted file mode 100644
index d7e5cbb5a1..0000000000
--- a/ext/spl/tests/spl_minheap_compare_error.phpt
+++ /dev/null
@@ -1,30 +0,0 @@
---TEST--
-SPL: SplMinHeap compare, illegal number of args
---CREDITS--
-Mark Schaschke (mark@fractalturtle.com)
-TestFest London May 2009
---FILE--
-<?php
-class SplMinHeap2 extends SplMinHeap {
- public function testCompare1() {
- return parent::compare();
- }
- public function testCompare2() {
- return parent::compare(1);
- }
- public function testCompare3() {
- return parent::compare(1, 2, 3);
- }
-}
-
-$h = new SplMinHeap2();
-$h->testCompare1();
-$h->testCompare2();
-$h->testCompare3();
-?>
---EXPECTF--
-Warning: SplMinHeap::compare() expects exactly 2 parameters, 0 given in %s
-
-Warning: SplMinHeap::compare() expects exactly 2 parameters, 1 given in %s
-
-Warning: SplMinHeap::compare() expects exactly 2 parameters, 3 given in %s
diff --git a/ext/spl/tests/spl_pq_top_error_args.phpt b/ext/spl/tests/spl_pq_top_error_args.phpt
deleted file mode 100644
index 8e26c6c7b8..0000000000
--- a/ext/spl/tests/spl_pq_top_error_args.phpt
+++ /dev/null
@@ -1,12 +0,0 @@
---TEST--
-SPL: SplPriorityQueue: top too many arguments exception
---CREDITS--
-Nathaniel McHugh nat@fishtrap.co.uk
-#testfest London 2009-05-09
---FILE--
-<?php
-$priorityQueue = new SplPriorityQueue();
-$priorityQueue->top('var');
-?>
---EXPECTF--
-Warning: SplPriorityQueue::top() expects exactly 0 parameters, 1 given in %s
diff --git a/ext/spl/tests/spl_pqueue_gc.phpt b/ext/spl/tests/spl_pqueue_gc.phpt
new file mode 100644
index 0000000000..cc392cbac2
--- /dev/null
+++ b/ext/spl/tests/spl_pqueue_gc.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Bug #78436: Broken GC for SplPriorityQueue
+--FILE--
+<?php
+
+$pqueue = new SplPriorityQueue();
+$pqueue->insert($pqueue, 1);
+
+$pqueue2 = new SplPriorityQueue();
+$pqueue2->insert(1, $pqueue);
+
+?>
+===DONE===
+--EXPECT--
+===DONE===
diff --git a/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt b/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt
deleted file mode 100644
index 076c687712..0000000000
--- a/ext/spl/tests/spl_priorityqeue_insert_two_params_error.phpt
+++ /dev/null
@@ -1,31 +0,0 @@
---TEST--
-SPL: priorityQueue parameter test on insert method
---CREDITS--
-Sean Burlington www.practicalweb.co.uk
-TestFest London May 2009
---FILE--
-<?php
-
-
-$testHeap = new SplPriorityQueue();
-
-
-var_dump($testHeap->insert());
-var_dump($testHeap->insert('test'));
-var_dump($testHeap->insert('test', 'test'));
-var_dump($testHeap->insert('test', 'test', 'test'));
-
-
-?>
-===DONE===
---EXPECTF--
-Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 0 given in %s on line 7
-NULL
-
-Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 1 given in %s on line 8
-NULL
-bool(true)
-
-Warning: SplPriorityQueue::insert() expects exactly 2 parameters, 3 given in %s on line 10
-NULL
-===DONE===
diff --git a/ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt b/ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt
deleted file mode 100644
index d52a3208ec..0000000000
--- a/ext/spl/tests/spl_recursiveIteratorIterator_setMaxDepth_parameter_count.phpt
+++ /dev/null
@@ -1,28 +0,0 @@
---TEST--
-SPL: RecursiveIteratorIterator, setMaxDepth check parameter count
---CREDITS--
-Sean Burlington www.practicalweb.co.uk
-TestFest London May 2009
---FILE--
-<?php
- //line 681 ...
- $array = array(array(7,8,9),1,2,3,array(4,5,6));
-$recursiveArrayIterator = new RecursiveArrayIterator($array);
-$test = new RecursiveIteratorIterator($recursiveArrayIterator);
-
-//var_dump($test->current());
-$test->setMaxDepth();
-$test->setMaxDepth(1);
-$test->setMaxDepth(1,2);
-$test->setMaxDepth(1,2,3);
-
-//var_dump($test->current());
-
-
-?>
-===DONE===
---EXPECTF--
-Warning: RecursiveIteratorIterator::setMaxDepth() expects at most 1 parameter, 2 given in %s on line 10
-
-Warning: RecursiveIteratorIterator::setMaxDepth() expects at most 1 parameter, 3 given in %s on line 11
-===DONE===
diff --git a/ext/spl/tests/splpriorityqueue_extract.phpt b/ext/spl/tests/splpriorityqueue_extract.phpt
deleted file mode 100644
index c3af4dd8f1..0000000000
--- a/ext/spl/tests/splpriorityqueue_extract.phpt
+++ /dev/null
@@ -1,17 +0,0 @@
---TEST--
-SPL: splpriorityqueue extract() Test arguments
---CREDITS--
-Roshan Abraham (roshanabrahams@gmail.com)
-TestFest London May 2009
---FILE--
-<?php
-
-$sp = new SplPriorityQueue();
-
-$sp->insert("1",1);
-
-$sp->extract(1); // Should throw a warning as extract expects NO arguments
-
-?>
---EXPECTF--
-Warning: SplPriorityQueue::extract() expects exactly 0 parameters, 1 given in %s on line %d
diff --git a/ext/spl/tests/splpriorityqueue_setextractflags.phpt b/ext/spl/tests/splpriorityqueue_setextractflags.phpt
deleted file mode 100644
index 0326dbb03c..0000000000
--- a/ext/spl/tests/splpriorityqueue_setextractflags.phpt
+++ /dev/null
@@ -1,15 +0,0 @@
---TEST--
-SPL: splpriorityqueue setExtractFlags() Test arguments
---CREDITS--
-Roshan Abraham (roshanabrahams@gmail.com)
-TestFest London May 2009
---FILE--
-<?php
-
-$sp = new SplPriorityQueue();
-
-$sp->setExtractFlags(1,1); // Should throw a warning as setExtractFlags expects only 1 argument
-
-?>
---EXPECTF--
-Warning: SplPriorityQueue::setExtractFlags() expects exactly 1 parameter, 2 given in %s on line %d
diff --git a/ext/spl/tests/testclass b/ext/spl/tests/testclass
index ceb24c877c..ceb24c877c 100755..100644
--- a/ext/spl/tests/testclass
+++ b/ext/spl/tests/testclass
diff --git a/ext/spl/tests/unserialize_errors.phpt b/ext/spl/tests/unserialize_errors.phpt
new file mode 100644
index 0000000000..237d0673c4
--- /dev/null
+++ b/ext/spl/tests/unserialize_errors.phpt
@@ -0,0 +1,138 @@
+--TEST--
+Errors from __unserialize() with invalid data
+--FILE--
+<?php
+
+echo "ArrayObject:\n";
+
+try {
+ unserialize('O:11:"ArrayObject":0:{}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:11:"ArrayObject":3:{i:0;b:1;i:1;a:0:{}i:2;a:0:{}}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:11:"ArrayObject":3:{i:0;i:0;i:1;a:0:{}i:2;i:0;}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:11:"ArrayObject":3:{i:0;i:0;i:1;i:0;i:2;a:0:{}}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+echo "ArrayIterator:\n";
+
+try {
+ unserialize('O:13:"ArrayIterator":0:{}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:13:"ArrayIterator":3:{i:0;b:1;i:1;a:0:{}i:2;a:0:{}}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:13:"ArrayIterator":3:{i:0;i:0;i:1;a:0:{}i:2;i:0;}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:13:"ArrayIterator":3:{i:0;i:0;i:1;i:0;i:2;a:0:{}}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+echo "SplDoublyLinkedList:\n";
+
+try {
+ unserialize('O:19:"SplDoublyLinkedList":0:{}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:19:"SplDoublyLinkedList":3:{i:0;b:1;i:1;a:0:{}i:2;a:0:{}}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:19:"SplDoublyLinkedList":3:{i:0;i:0;i:1;a:0:{}i:2;i:0;}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:19:"SplDoublyLinkedList":3:{i:0;i:0;i:1;i:0;i:2;a:0:{}}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+echo "SplObjectStorage:\n";
+
+try {
+ unserialize('O:16:"SplObjectStorage":0:{}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:16:"SplObjectStorage":2:{i:0;i:0;i:1;a:0:{}}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:16:"SplObjectStorage":2:{i:0;a:0:{}i:1;i:1;}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:16:"SplObjectStorage":2:{i:0;a:1:{i:0;i:0;}i:1;a:0:{}}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+try {
+ unserialize('O:16:"SplObjectStorage":2:{i:0;a:2:{i:0;i:0;i:1;i:0;}i:1;a:0:{}}');
+} catch (Exception $e) {
+ echo $e->getMessage(), "\n";
+}
+
+?>
+--EXPECTF--
+ArrayObject:
+Incomplete or ill-typed serialization data
+Incomplete or ill-typed serialization data
+Incomplete or ill-typed serialization data
+Passed variable is not an array or object
+ArrayIterator:
+Incomplete or ill-typed serialization data
+Incomplete or ill-typed serialization data
+Incomplete or ill-typed serialization data
+Passed variable is not an array or object
+SplDoublyLinkedList:
+Incomplete or ill-typed serialization data
+Incomplete or ill-typed serialization data
+Incomplete or ill-typed serialization data
+Incomplete or ill-typed serialization data
+SplObjectStorage:
+Incomplete or ill-typed serialization data
+Incomplete or ill-typed serialization data
+Incomplete or ill-typed serialization data
+Odd number of elements
+Non-object key