diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index ce468267d089a..c8299217d8aa0 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -1082,6 +1082,7 @@ static void spl_array_it_rewind(zend_object_iterator *iter) /* {{{ */ /* {{{ spl_array_set_array */ static void spl_array_set_array(zval *object, spl_array_object *intern, zval *array, zend_long ar_flags, int just_array) { if (Z_TYPE_P(array) != IS_OBJECT && Z_TYPE_P(array) != IS_ARRAY) { + // TODO Type Error? zend_throw_exception(spl_ce_InvalidArgumentException, "Passed variable is not an array or object", 0); return; } @@ -1144,7 +1145,7 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object, spl_array_object *array_object = Z_SPLARRAY_P(object); if (by_ref && (array_object->ar_flags & SPL_ARRAY_OVERLOADED_CURRENT)) { - zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0); + zend_throw_error(NULL, "An iterator cannot be used with foreach by reference"); return NULL; } diff --git a/ext/spl/spl_directory.c b/ext/spl/spl_directory.c index 72fb1cbe8f575..cc5e4b7ac4849 100644 --- a/ext/spl/spl_directory.c +++ b/ext/spl/spl_directory.c @@ -52,10 +52,9 @@ PHPAPI zend_class_entry *spl_ce_GlobIterator; PHPAPI zend_class_entry *spl_ce_SplFileObject; PHPAPI zend_class_entry *spl_ce_SplTempFileObject; -// TODO Use standard Error #define CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(spl_filesystem_object_pointer) \ if (!(spl_filesystem_object_pointer)->u.file.stream) { \ - zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized"); \ + zend_throw_error(NULL, "Object not initialized"); \ RETURN_THROWS(); \ } @@ -209,7 +208,7 @@ static inline int spl_filesystem_object_get_file_name(spl_filesystem_object *int case SPL_FS_INFO: case SPL_FS_FILE: if (!intern->file_name) { - zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized"); + zend_throw_error(NULL, "Object not initialized"); return FAILURE; } break; @@ -721,19 +720,19 @@ void spl_filesystem_object_construct(INTERNAL_FUNCTION_PARAMETERS, zend_long cto flags |= SPL_FILE_DIR_UNIXPATHS; } if (parsed == FAILURE) { - return; + RETURN_THROWS(); } - if (!len) { - zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Directory name must not be empty."); - return; + if (len == 0) { + zend_argument_value_error(1, "cannot be empty"); + RETURN_THROWS(); } intern = Z_SPLFILESYSTEM_P(ZEND_THIS); if (intern->_path) { /* object is already initialized */ zend_throw_error(NULL, "Directory object is already initialized"); - return; + RETURN_THROWS(); } intern->flags = flags; @@ -1393,9 +1392,7 @@ PHP_METHOD(SplFileInfo, __debugInfo) /* {{{ */ PHP_METHOD(SplFileInfo, _bad_state_ex) { - zend_throw_exception_ex(spl_ce_LogicException, 0, - "The parent constructor was not called: the object is in an " - "invalid state "); + zend_throw_error(NULL, "The parent constructor was not called: the object is in an invalid state"); } /* }}} */ @@ -1612,7 +1609,7 @@ zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval spl_filesystem_object *dir_object; if (by_ref) { - zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0); + zend_throw_error(NULL, "An iterator cannot be used with foreach by reference"); return NULL; } dir_object = Z_SPLFILESYSTEM_P(object); @@ -1819,7 +1816,7 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva spl_filesystem_object *dir_object; if (by_ref) { - zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0); + zend_throw_error(NULL, "An iterator cannot be used with foreach by reference"); return NULL; } dir_object = Z_SPLFILESYSTEM_P(object); @@ -2021,7 +2018,7 @@ static int spl_filesystem_file_read_line(zval * this_ptr, spl_filesystem_object static void spl_filesystem_file_rewind(zval * this_ptr, spl_filesystem_object *intern) /* {{{ */ { if (!intern->u.file.stream) { - zend_throw_exception_ex(spl_ce_RuntimeException, 0, "Object not initialized"); + zend_throw_error(NULL, "Object not initialized"); return; } if (-1 == php_stream_rewind(intern->u.file.stream)) { @@ -2280,7 +2277,7 @@ PHP_METHOD(SplFileObject, setMaxLineLen) } if (max_len < 0) { - zend_throw_exception_ex(spl_ce_DomainException, 0, "Maximum line length must be greater than or equal zero"); + zend_argument_value_error(1, "must be greater than or equal to 0"); RETURN_THROWS(); } @@ -2727,7 +2724,7 @@ PHP_METHOD(SplFileObject, seek) CHECK_SPL_FILE_OBJECT_IS_INITIALIZED(intern); if (line_pos < 0) { - zend_throw_exception_ex(spl_ce_LogicException, 0, "Can't seek file %s to negative line " ZEND_LONG_FMT, intern->file_name, line_pos); + zend_argument_value_error(1, "must be greater than or equal to 0"); RETURN_THROWS(); } diff --git a/ext/spl/spl_dllist.c b/ext/spl/spl_dllist.c index eb01c09d80fc7..c576104139315 100644 --- a/ext/spl/spl_dllist.c +++ b/ext/spl/spl_dllist.c @@ -1308,7 +1308,7 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object spl_dllist_object *dllist_object = Z_SPLDLLIST_P(object); if (by_ref) { - zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0); + zend_throw_error(NULL, "An iterator cannot be used with foreach by reference"); return NULL; } diff --git a/ext/spl/spl_fixedarray.c b/ext/spl/spl_fixedarray.c index 558514eec1e50..915e55f17cc6c 100644 --- a/ext/spl/spl_fixedarray.c +++ b/ext/spl/spl_fixedarray.c @@ -529,7 +529,7 @@ PHP_METHOD(SplFixedArray, __construct) } if (size < 0) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "array size cannot be less than zero"); + zend_argument_value_error(1, "must be greater than or equal to 0"); RETURN_THROWS(); } @@ -704,7 +704,7 @@ PHP_METHOD(SplFixedArray, setSize) } if (size < 0) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "array size cannot be less than zero"); + zend_argument_value_error(1, "must be greater than or equal to 0"); RETURN_THROWS(); } @@ -955,7 +955,7 @@ zend_object_iterator *spl_fixedarray_get_iterator(zend_class_entry *ce, zval *ob spl_fixedarray_it *iterator; if (by_ref) { - zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0); + zend_throw_error(NULL, "An iterator cannot be used with foreach by reference"); return NULL; } diff --git a/ext/spl/spl_heap.c b/ext/spl/spl_heap.c index 0beea11da0780..ba1b0fd68160f 100644 --- a/ext/spl/spl_heap.c +++ b/ext/spl/spl_heap.c @@ -1066,7 +1066,7 @@ zend_object_iterator *spl_heap_get_iterator(zend_class_entry *ce, zval *object, spl_heap_object *heap_object = Z_SPLHEAP_P(object); if (by_ref) { - zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0); + zend_throw_error(NULL, "An iterator cannot be used with foreach by reference"); return NULL; } @@ -1091,7 +1091,7 @@ zend_object_iterator *spl_pqueue_get_iterator(zend_class_entry *ce, zval *object spl_heap_object *heap_object = Z_SPLHEAP_P(object); if (by_ref) { - zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0); + zend_throw_error(NULL, "An iterator cannot be used with foreach by reference"); return NULL; } diff --git a/ext/spl/spl_iterators.c b/ext/spl/spl_iterators.c index d245cc356731b..731f7f7b6e866 100644 --- a/ext/spl/spl_iterators.c +++ b/ext/spl/spl_iterators.c @@ -125,8 +125,7 @@ static inline spl_recursive_it_object *spl_recursive_it_from_obj(zend_object *ob do { \ spl_dual_it_object *it = Z_SPLDUAL_IT_P(objzval); \ if (it->dit_type == DIT_Unknown) { \ - zend_throw_exception_ex(spl_ce_LogicException, 0, \ - "The object is in an invalid state as the parent constructor was not called"); \ + zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); \ RETURN_THROWS(); \ } \ (var) = it; \ @@ -135,8 +134,7 @@ static inline spl_recursive_it_object *spl_recursive_it_from_obj(zend_object *ob #define SPL_FETCH_SUB_ELEMENT(var, object, element) \ do { \ if(!(object)->iterators) { \ - zend_throw_exception_ex(spl_ce_LogicException, 0, \ - "The object is in an invalid state as the parent constructor was not called"); \ + zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); \ return; \ } \ (var) = (object)->iterators[(object)->level].element; \ @@ -145,8 +143,7 @@ static inline spl_recursive_it_object *spl_recursive_it_from_obj(zend_object *ob #define SPL_FETCH_SUB_ELEMENT_ADDR(var, object, element) \ do { \ if(!(object)->iterators) { \ - zend_throw_exception_ex(spl_ce_LogicException, 0, \ - "The object is in an invalid state as the parent constructor was not called"); \ + zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); \ RETURN_THROWS(); \ } \ (var) = &(object)->iterators[(object)->level].element; \ @@ -448,7 +445,7 @@ static zend_object_iterator *spl_recursive_it_get_iterator(zend_class_entry *ce, spl_recursive_it_object *object; if (by_ref) { - zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0); + zend_throw_error(NULL, "An iterator cannot be used with foreach by reference"); return NULL; } iterator = emalloc(sizeof(spl_recursive_it_iterator)); @@ -698,8 +695,7 @@ PHP_METHOD(RecursiveIteratorIterator, getSubIterator) } if(!object->iterators) { - zend_throw_exception_ex(spl_ce_LogicException, 0, - "The object is in an invalid state as the parent constructor was not called"); + zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); RETURN_THROWS(); } @@ -829,7 +825,7 @@ PHP_METHOD(RecursiveIteratorIterator, setMaxDepth) RETURN_THROWS(); } if (max_depth < -1) { - zend_throw_exception(spl_ce_OutOfRangeException, "Parameter max_depth must be >= -1", 0); + zend_argument_value_error(1, "must be greater than or equal to -1"); RETURN_THROWS(); } else if (max_depth > INT_MAX) { max_depth = INT_MAX; @@ -1041,7 +1037,7 @@ PHP_METHOD(RecursiveTreeIterator, setPrefixPart) } if (0 > part || part > 5) { - zend_throw_exception_ex(spl_ce_OutOfRangeException, 0, "Use RecursiveTreeIterator::PREFIX_* constant"); + zend_argument_value_error(1, "must be a RecursiveTreeIterator::PREFIX_* constant"); RETURN_THROWS(); } @@ -1059,8 +1055,7 @@ PHP_METHOD(RecursiveTreeIterator, getPrefix) } if(!object->iterators) { - zend_throw_exception_ex(spl_ce_LogicException, 0, - "The object is in an invalid state as the parent constructor was not called"); + zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); RETURN_THROWS(); } @@ -1092,8 +1087,7 @@ PHP_METHOD(RecursiveTreeIterator, getEntry) } if(!object->iterators) { - zend_throw_exception_ex(spl_ce_LogicException, 0, - "The object is in an invalid state as the parent constructor was not called"); + zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); RETURN_THROWS(); } @@ -1110,8 +1104,7 @@ PHP_METHOD(RecursiveTreeIterator, getPostfix) } if(!object->iterators) { - zend_throw_exception_ex(spl_ce_LogicException, 0, - "The object is in an invalid state as the parent constructor was not called"); + zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); RETURN_THROWS(); } @@ -1131,8 +1124,7 @@ PHP_METHOD(RecursiveTreeIterator, current) } if(!object->iterators) { - zend_throw_exception_ex(spl_ce_LogicException, 0, - "The object is in an invalid state as the parent constructor was not called"); + zend_throw_error(NULL, "The object is in an invalid state as the parent constructor was not called"); RETURN_THROWS(); } @@ -1254,6 +1246,7 @@ static zend_function *spl_dual_it_get_method(zend_object **object, zend_string * #define SPL_CHECK_CTOR(intern, classname) \ if (intern->dit_type == DIT_Unknown) { \ + /* TODO Normal Error? */ \ zend_throw_exception_ex(spl_ce_BadMethodCallException, 0, "Classes derived from %s must call %s::__construct()", \ ZSTR_VAL((spl_ce_##classname)->name), ZSTR_VAL((spl_ce_##classname)->name)); \ RETURN_THROWS(); \ @@ -1298,11 +1291,11 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z return NULL; } if (intern->u.limit.offset < 0) { - zend_throw_exception(spl_ce_OutOfRangeException, "Parameter offset must be >= 0", 0); + zend_argument_value_error(2, "must be greater than or equal to 0"); return NULL; } - if (intern->u.limit.count < 0 && intern->u.limit.count != -1) { - zend_throw_exception(spl_ce_OutOfRangeException, "Parameter count must either be -1 or a value greater than or equal 0", 0); + if (intern->u.limit.count < -1) { + zend_argument_value_error(3, "must be greater than or equal to -1"); return NULL; } break; @@ -1314,7 +1307,9 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z return NULL; } if (spl_cit_check_flags(flags) != SUCCESS) { - zend_throw_exception(spl_ce_InvalidArgumentException, "Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER", 0); + zend_argument_value_error(2, "must contain only one of CachingIterator::CALL_TOSTRING, " + "CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, " + "or CachingIterator::TOSTRING_USE_INNER"); return NULL; } intern->u.caching.flags |= flags & CIT_PUBLIC; @@ -1382,7 +1377,8 @@ static spl_dual_it_object* spl_dual_it_construct(INTERNAL_FUNCTION_PARAMETERS, z return NULL; } if (mode < 0 || mode >= REGIT_MODE_MAX) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Illegal mode " ZEND_LONG_FMT, mode); + zend_argument_value_error(3, "must be RegexIterator::MATCH, RegexIterator::GET_MATCH, " + "RegexIterator::ALL_MATCHES, RegexIterator::SPLIT, or RegexIterator::REPLACE"); return NULL; } @@ -1929,7 +1925,8 @@ PHP_METHOD(RegexIterator, setMode) } if (mode < 0 || mode >= REGIT_MODE_MAX) { - zend_throw_exception_ex(spl_ce_InvalidArgumentException, 0, "Illegal mode " ZEND_LONG_FMT, mode); + zend_argument_value_error(1, "must be RegexIterator::MATCH, RegexIterator::GET_MATCH, " + "RegexIterator::ALL_MATCHES, RegexIterator::SPLIT, or RegexIterator::REPLACE"); RETURN_THROWS(); } @@ -2584,7 +2581,9 @@ PHP_METHOD(CachingIterator, setFlags) SPL_FETCH_AND_CHECK_DUAL_IT(intern, ZEND_THIS); if (spl_cit_check_flags(flags) != SUCCESS) { - zend_throw_exception(spl_ce_InvalidArgumentException , "Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER", 0); + zend_argument_value_error(1, "must contain only one of CachingIterator::CALL_TOSTRING, " + "CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, " + "or CachingIterator::TOSTRING_USE_INNER"); RETURN_THROWS(); } if ((intern->u.caching.flags & CIT_CALL_TOSTRING) != 0 && (flags & CIT_CALL_TOSTRING) == 0) { diff --git a/ext/spl/tests/DirectoryIterator_by_reference.phpt b/ext/spl/tests/DirectoryIterator_by_reference.phpt index 0f28262190b33..a6af6569c9f09 100644 --- a/ext/spl/tests/DirectoryIterator_by_reference.phpt +++ b/ext/spl/tests/DirectoryIterator_by_reference.phpt @@ -11,7 +11,7 @@ foreach( $it as &$file ) { } ?> --EXPECTF-- -Fatal error: Uncaught RuntimeException: An iterator cannot be used with foreach by reference in %s:%d +Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in %s:%d Stack trace: #0 {main} thrown in %s on line %d diff --git a/ext/spl/tests/DirectoryIterator_empty_constructor.phpt b/ext/spl/tests/DirectoryIterator_empty_constructor.phpt index cf96425892603..a2ae3f065c13e 100644 --- a/ext/spl/tests/DirectoryIterator_empty_constructor.phpt +++ b/ext/spl/tests/DirectoryIterator_empty_constructor.phpt @@ -5,11 +5,11 @@ Havard Eide #PHPTestFest2009 Norway 2009-06-09 \o/ --FILE-- getMessage() . \PHP_EOL; +} ?> ---EXPECTF-- -Fatal error: Uncaught RuntimeException: Directory name must not be empty. in %s:%d -Stack trace: -#0 %s(%d): DirectoryIterator->__construct('') -#1 {main} - thrown in %s on line %d +--EXPECT-- +DirectoryIterator::__construct(): Argument #1 ($path) cannot be empty diff --git a/ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt b/ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt index 8c3aad3ef7dba..769136c4064fa 100644 --- a/ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt +++ b/ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt @@ -17,7 +17,7 @@ try { $value *= $value; echo $value, PHP_EOL; } -} catch (Exception $e) { +} catch (\Error $e) { echo $e->getMessage(), PHP_EOL; } diff --git a/ext/spl/tests/SplFileObject_seek_error_001.phpt b/ext/spl/tests/SplFileObject_seek_error_001.phpt index acebb66f41569..30ad772958555 100644 --- a/ext/spl/tests/SplFileObject_seek_error_001.phpt +++ b/ext/spl/tests/SplFileObject_seek_error_001.phpt @@ -5,9 +5,9 @@ SplFileObject::seek function - test parameters $obj = new SplFileObject(__FILE__); try { $obj->seek(-1); -} catch (LogicException $e) { +} catch (\ValueError $e) { echo($e->getMessage()); } ?> ---EXPECTF-- -Can't seek file %s to negative line -1 +--EXPECT-- +SplFileObject::seek(): Argument #1 ($line_pos) must be greater than or equal to 0 diff --git a/ext/spl/tests/array_019.phpt b/ext/spl/tests/array_019.phpt index 2a86e70589381..7d1239c0bdc4f 100644 --- a/ext/spl/tests/array_019.phpt +++ b/ext/spl/tests/array_019.phpt @@ -26,7 +26,7 @@ int(2) int(3) int(4) -Fatal error: Uncaught RuntimeException: An iterator cannot be used with foreach by reference in %s:%d +Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in %s:%d Stack trace: #0 {main} thrown in %s on line %d diff --git a/ext/spl/tests/bug51119.phpt b/ext/spl/tests/bug51119.phpt index aba523dc62955..2f3348a2c4931 100644 --- a/ext/spl/tests/bug51119.phpt +++ b/ext/spl/tests/bug51119.phpt @@ -6,22 +6,15 @@ SPL: LimitIterator zero is valid offset $array = array('a', 'b', 'c'); $arrayIterator = new ArrayIterator($array); -try { - $limitIterator = new LimitIterator($arrayIterator, 0); - foreach ($limitIterator as $item) { +$limitIterator = new LimitIterator($arrayIterator, 0); +foreach ($limitIterator as $item) { echo $item . "\n"; - } -} catch (OutOfRangeException $e){ - print $e->getMessage() . "\n"; } try { - $limitIterator = new LimitIterator($arrayIterator, -1); - foreach ($limitIterator as $item) { - echo $item . "\n"; - } -} catch (OutOfRangeException $e){ - print $e->getMessage() . "\n"; + $limitIterator = new LimitIterator($arrayIterator, -1); +} catch (\ValueError $e){ + print $e->getMessage() . "\n"; } ?> @@ -29,4 +22,4 @@ try { a b c -Parameter offset must be >= 0 +LimitIterator::__construct(): Argument #2 ($offset) must be greater than or equal to 0 diff --git a/ext/spl/tests/bug54281.phpt b/ext/spl/tests/bug54281.phpt index 5d214d9b18b3a..a2dbcd74476f0 100644 --- a/ext/spl/tests/bug54281.phpt +++ b/ext/spl/tests/bug54281.phpt @@ -12,7 +12,7 @@ foreach($it as $k=>$v) { } ?> --EXPECTF-- -Fatal error: Uncaught LogicException: The object is in an invalid state as the parent constructor was not called in %s:%d +Fatal error: Uncaught Error: The object is in an invalid state as the parent constructor was not called in %s:%d Stack trace: #0 %s%ebug54281.php(8): RecursiveIteratorIterator->rewind() #1 {main} diff --git a/ext/spl/tests/bug54384.phpt b/ext/spl/tests/bug54384.phpt index aa2d6fdb93b8a..fa02e372f524d 100644 --- a/ext/spl/tests/bug54384.phpt +++ b/ext/spl/tests/bug54384.phpt @@ -7,8 +7,8 @@ function test($f) { try { $f(); echo "ran normally (unexpected)\n\n"; - } catch (LogicException $e) { - echo "exception (expected)\n"; + } catch (\Error $e) { + echo "Error (expected)\n"; } } @@ -154,18 +154,18 @@ echo $a,"\n"; } ); ?> --EXPECT-- -IteratorIterator... exception (expected) -FilterIterator... exception (expected) -RecursiveFilterIterator... exception (expected) -ParentIterator... exception (expected) -LimitIterator... exception (expected) -CachingIterator... exception (expected) -RecursiveCachingIterator... exception (expected) -NoRewindIterator... exception (expected) -RegexIterator... exception (expected) -RecursiveRegexIterator... exception (expected) -GlobIterator... exception (expected) -SplFileObject... exception (expected) -SplTempFileObject... exception (expected) -AppendIterator... exception (expected) -InfiniteIterator... exception (expected) +IteratorIterator... Error (expected) +FilterIterator... Error (expected) +RecursiveFilterIterator... Error (expected) +ParentIterator... Error (expected) +LimitIterator... Error (expected) +CachingIterator... Error (expected) +RecursiveCachingIterator... Error (expected) +NoRewindIterator... Error (expected) +RegexIterator... Error (expected) +RecursiveRegexIterator... Error (expected) +GlobIterator... Error (expected) +SplFileObject... Error (expected) +SplTempFileObject... Error (expected) +AppendIterator... Error (expected) +InfiniteIterator... Error (expected) diff --git a/ext/spl/tests/bug55701.phpt b/ext/spl/tests/bug55701.phpt index 737ebf2184b52..69b9eb0abb384 100644 --- a/ext/spl/tests/bug55701.phpt +++ b/ext/spl/tests/bug55701.phpt @@ -15,7 +15,7 @@ function testBaseClass($f) { } catch (RuntimeException $e) { // Throwing a RuntimeException is the correct behaviour for some methods echo "ran normally (expected)\n"; - } catch (LogicException $e) { + } catch (\Error $e) { // Throwing a LogicException is not correct echo "threw LogicException (unexpected)\n"; } @@ -27,8 +27,8 @@ function testChildClass($f) { try { $f(); echo "didn't throw (unexpected)\n"; - } catch (LogicException $e) { - echo "threw LogicException (expected)\n"; + } catch (\Error $e) { + echo "threw Error (expected)\n"; } catch (Exception $e) { echo "threw other exception (unexpected)\n"; } @@ -330,6 +330,6 @@ non-empty GlobIterator... ran normally (expected) ======================= test there are no regressions ======================= SplFileObject existent file... ran normally (expected) SplFileObject non-existent file... ran normally (expected) -extends GlobIterator... threw LogicException (expected) -extends SplFileObject... threw LogicException (expected) -extends SplTempFileObject... threw LogicException (expected) +extends GlobIterator... threw Error (expected) +extends SplFileObject... threw Error (expected) +extends SplTempFileObject... threw Error (expected) diff --git a/ext/spl/tests/bug79710.phpt b/ext/spl/tests/bug79710.phpt index a5c065fd67ba6..8bfaddb0f8c88 100644 --- a/ext/spl/tests/bug79710.phpt +++ b/ext/spl/tests/bug79710.phpt @@ -32,7 +32,7 @@ Run::main(); ?> --EXPECTF-- -Fatal error: Uncaught RuntimeException: Object not initialized in %s:%d +Fatal error: Uncaught Error: Object not initialized in %s:%d Stack trace: #0 %s(%d): SplFileObject->flock(2) #1 [internal function]: Target->__destruct() diff --git a/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt b/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt index 6bfdfdcf50994..5a4229616a322 100644 --- a/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt +++ b/ext/spl/tests/fileobject_setmaxlinelen_error001.phpt @@ -8,10 +8,10 @@ $s = new SplFileObject( __FILE__ ); try { $s->setMaxLineLen(-1); } -catch (DomainException $e) { - echo 'DomainException thrown'; +catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } ?> --EXPECT-- -DomainException thrown +SplFileObject::setMaxLineLen(): Argument #1 ($max_len) must be greater than or equal to 0 diff --git a/ext/spl/tests/fixedarray_021.phpt b/ext/spl/tests/fixedarray_021.phpt index db4962ef481be..376985fd5d28f 100644 --- a/ext/spl/tests/fixedarray_021.phpt +++ b/ext/spl/tests/fixedarray_021.phpt @@ -12,16 +12,16 @@ var_dump($a->count()); /* negative init value */ try { $b = new SplFixedArray(-10); -} catch (Exception $e) { - var_dump($e->getMessage()); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } /* resize and negative value */ $b = new SplFixedArray(); try { $b->setSize(-5); -} catch (Exception $e) { - var_dump($e->getMessage()); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } /* calling __construct() twice */ @@ -46,7 +46,7 @@ try { foreach ($e as $k=>&$v) { var_dump($v); } -} catch (Exception $e) { +} catch (\Error $e) { var_dump($e->getMessage()); } @@ -63,8 +63,8 @@ var_dump(empty($a["3"])); --EXPECTF-- int(0) int(0) -string(35) "array size cannot be less than zero" -string(35) "array size cannot be less than zero" +SplFixedArray::__construct(): Argument #1 ($size) must be greater than or equal to 0 +SplFixedArray::setSize(): Argument #1 ($size) must be greater than or equal to 0 NULL int(0) int(0) diff --git a/ext/spl/tests/heap_009.phpt b/ext/spl/tests/heap_009.phpt index 39d0a19f4be66..833d079b253b5 100644 --- a/ext/spl/tests/heap_009.phpt +++ b/ext/spl/tests/heap_009.phpt @@ -11,7 +11,7 @@ function testForException( $heap ) { foreach( $heap as &$item ); } - catch( RuntimeException $e ) + catch( \Error $e ) { echo $e->getMessage(),"\n"; } diff --git a/ext/spl/tests/iterator_028.phpt b/ext/spl/tests/iterator_028.phpt index 5d681ccac05ef..0b8253d25b382 100644 --- a/ext/spl/tests/iterator_028.phpt +++ b/ext/spl/tests/iterator_028.phpt @@ -39,14 +39,11 @@ foreach($it as $v) echo $it->getDepth() . ": $v\n"; echo "===-1===\n"; $it->setMaxDepth(-1); var_dump($it->getMaxDepth()); -try -{ - $it->setMaxDepth(4); +$it->setMaxDepth(4); +try { $it->setMaxDepth(-2); -} -catch(Exception $e) -{ - var_dump($e->getMessage()); +} catch(\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } var_dump($it->getMaxDepth()); ?> @@ -105,5 +102,5 @@ int(0) 0: 4 ===-1=== bool(false) -string(33) "Parameter max_depth must be >= -1" +RecursiveIteratorIterator::setMaxDepth(): Argument #1 ($max_depth) must be greater than or equal to -1 int(4) diff --git a/ext/spl/tests/iterator_031.phpt b/ext/spl/tests/iterator_031.phpt index 247e13bfff08a..d1aed21ac0692 100644 --- a/ext/spl/tests/iterator_031.phpt +++ b/ext/spl/tests/iterator_031.phpt @@ -56,7 +56,7 @@ try { $ap->append($it); } -catch(LogicException $e) +catch(\Error $e) { echo $e->getMessage() . "\n"; } diff --git a/ext/spl/tests/iterator_037.phpt b/ext/spl/tests/iterator_037.phpt index 1792b1cb66faa..baa15f36847d3 100644 --- a/ext/spl/tests/iterator_037.phpt +++ b/ext/spl/tests/iterator_037.phpt @@ -7,26 +7,20 @@ function test($ar, $flags) { echo "===$flags===\n"; $it = new CachingIterator($ar, 0); - try - { + try { $it->setFlags($flags); - } - catch (Exception $e) - { + } catch (\ValueError $e) { echo 'Exception: ' . $e->getMessage() . "\n"; var_dump($it->getFlags()); return; } var_dump($it->getFlags()); - try - { + try { foreach($it as $v) { var_dump((string)$it); } - } - catch (Exception $e) - { + } catch (Exception $e) { echo 'Exception: ' . $e->getMessage() . "\n"; } } @@ -110,19 +104,19 @@ string(3) "0:1" string(3) "1:2" string(3) "2:3" ===3=== -Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER +Exception: CachingIterator::setFlags(): Argument #1 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER int(0) ===5=== -Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER +Exception: CachingIterator::setFlags(): Argument #1 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER int(0) ===9=== -Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER +Exception: CachingIterator::setFlags(): Argument #1 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER int(0) ===6=== -Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER +Exception: CachingIterator::setFlags(): Argument #1 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER int(0) ===10=== -Exception: Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER +Exception: CachingIterator::setFlags(): Argument #1 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER int(0) ===X=== Exception: Unsetting flag CALL_TO_STRING is not possible diff --git a/ext/spl/tests/iterator_069.phpt b/ext/spl/tests/iterator_069.phpt index 975fbe2f8e194..b9ee3f4b820d9 100644 --- a/ext/spl/tests/iterator_069.phpt +++ b/ext/spl/tests/iterator_069.phpt @@ -14,7 +14,7 @@ foreach ($recItIt as &$val) echo "$val\n"; ?> --EXPECTF-- -Fatal error: Uncaught RuntimeException: An iterator cannot be used with foreach by reference in %s:%d +Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in %s:%d Stack trace: #0 {main} thrown in %s on line %d diff --git a/ext/spl/tests/recursive_tree_iterator_008.phpt b/ext/spl/tests/recursive_tree_iterator_008.phpt index fbdc3a5cb1790..2dd531882463e 100644 --- a/ext/spl/tests/recursive_tree_iterator_008.phpt +++ b/ext/spl/tests/recursive_tree_iterator_008.phpt @@ -20,14 +20,13 @@ foreach($it as $k => $v) { } try { $it->setPrefixPart(-1, ""); - $it->setPrefixPart(6, ""); -} catch (OutOfRangeException $e) { - echo "OutOfRangeException thrown\n"; +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } try { $it->setPrefixPart(6, ""); -} catch (OutOfRangeException $e) { - echo "OutOfRangeException thrown\n"; +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; } ?> --EXPECT-- @@ -35,5 +34,5 @@ try { [0] => 0145b [c] => 045Array [0] => 0245d -OutOfRangeException thrown -OutOfRangeException thrown +RecursiveTreeIterator::setPrefixPart(): Argument #1 ($part) must be a RecursiveTreeIterator::PREFIX_* constant +RecursiveTreeIterator::setPrefixPart(): Argument #1 ($part) must be a RecursiveTreeIterator::PREFIX_* constant diff --git a/ext/spl/tests/regexIterator_setMode_error.phpt b/ext/spl/tests/regexIterator_setMode_error.phpt index 3b0eaf1d66c1e..10df255f4a012 100644 --- a/ext/spl/tests/regexIterator_setMode_error.phpt +++ b/ext/spl/tests/regexIterator_setMode_error.phpt @@ -12,13 +12,13 @@ var_dump($regexIterator->getMode()); try { $regexIterator->setMode(7); -} catch (InvalidArgumentException $e) { - var_dump($e->getMessage()); +} catch (\ValueError $e) { + echo $e->getMessage() . \PHP_EOL; var_dump($e->getCode()); } ?> --EXPECT-- int(0) -string(14) "Illegal mode 7" +RegexIterator::setMode(): Argument #1 ($mode) must be RegexIterator::MATCH, RegexIterator::GET_MATCH, RegexIterator::ALL_MATCHES, RegexIterator::SPLIT, or RegexIterator::REPLACE int(0) diff --git a/ext/spl/tests/spl_caching_iterator_constructor_flags.phpt b/ext/spl/tests/spl_caching_iterator_constructor_flags.phpt index 29bae9469d6f3..0d107d206f4af 100644 --- a/ext/spl/tests/spl_caching_iterator_constructor_flags.phpt +++ b/ext/spl/tests/spl_caching_iterator_constructor_flags.phpt @@ -8,16 +8,18 @@ TestFest London May 2009 //line 681 ... $array = array(array(7,8,9),1,2,3,array(4,5,6)); $arrayIterator = new ArrayIterator($array); +new CachingIterator($arrayIterator, 0); /* TODO Should this throw? */ +new CachingIterator($arrayIterator, CachingIterator::CALL_TOSTRING); +new CachingIterator($arrayIterator, CachingIterator::TOSTRING_USE_KEY); +new CachingIterator($arrayIterator, CachingIterator::TOSTRING_USE_CURRENT); +new CachingIterator($arrayIterator, CachingIterator::TOSTRING_USE_INNER); try { -$test = new CachingIterator($arrayIterator, 0); -$test = new CachingIterator($arrayIterator, 1); -$test = new CachingIterator($arrayIterator, 2); -$test = new CachingIterator($arrayIterator, 3); // this throws an exception -} catch (InvalidArgumentException $e){ + $test = new CachingIterator($arrayIterator, 3); // this throws an exception +} catch (\ValueError $e){ print $e->getMessage() . "\n"; } ?> --EXPECT-- -Flags must contain only one of CALL_TOSTRING, TOSTRING_USE_KEY, TOSTRING_USE_CURRENT, TOSTRING_USE_INNER +CachingIterator::__construct(): Argument #2 ($flags) must contain only one of CachingIterator::CALL_TOSTRING, CachingIterator::TOSTRING_USE_KEY, CachingIterator::TOSTRING_USE_CURRENT, or CachingIterator::TOSTRING_USE_INNER diff --git a/ext/spl/tests/spl_limit_iterator_check_limits.phpt b/ext/spl/tests/spl_limit_iterator_check_limits.phpt index 83b99b5c85894..91604abb3da44 100644 --- a/ext/spl/tests/spl_limit_iterator_check_limits.phpt +++ b/ext/spl/tests/spl_limit_iterator_check_limits.phpt @@ -10,26 +10,19 @@ $arrayIterator = new ArrayIterator($array); try { $limitIterator = new LimitIterator($arrayIterator, -1); -} catch (OutOfRangeException $e){ +} catch (\ValueError $e){ print $e->getMessage(). "\n"; } - try { $limitIterator = new LimitIterator($arrayIterator, 0, -2); -} catch (OutOfRangeException $e){ - print $e->getMessage() . "\n"; -} - -try { - $limitIterator = new LimitIterator($arrayIterator, 0, -1); -} catch (OutOfRangeException $e){ +} catch (\ValueError $e){ print $e->getMessage() . "\n"; } - +$limitIterator = new LimitIterator($arrayIterator, 0, -1); ?> --EXPECT-- -Parameter offset must be >= 0 -Parameter count must either be -1 or a value greater than or equal 0 +LimitIterator::__construct(): Argument #2 ($offset) must be greater than or equal to 0 +LimitIterator::__construct(): Argument #3 ($count) must be greater than or equal to -1