Skip to content

Commit

Permalink
Use normal error in SPL for 'An iterator cannot be used with foreach …
Browse files Browse the repository at this point in the history
…by reference'
  • Loading branch information
Girgias committed Sep 15, 2020
1 parent 4fc7026 commit 9affbef
Show file tree
Hide file tree
Showing 12 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion ext/spl/spl_array.c
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,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;
}

Expand Down
4 changes: 2 additions & 2 deletions ext/spl/spl_directory.c
Original file line number Diff line number Diff line change
Expand Up @@ -1612,7 +1612,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);
Expand Down Expand Up @@ -1819,7 +1819,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);
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_dllist.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_fixedarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
4 changes: 2 additions & 2 deletions ext/spl/spl_heap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion ext/spl/spl_iterators.c
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,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));
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/tests/DirectoryIterator_by_reference.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ try {
$value *= $value;
echo $value, PHP_EOL;
}
} catch (Exception $e) {
} catch (\Error $e) {
echo $e->getMessage(), PHP_EOL;
}

Expand Down
2 changes: 1 addition & 1 deletion ext/spl/tests/array_019.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion ext/spl/tests/fixedarray_021.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ try {
foreach ($e as $k=>&$v) {
var_dump($v);
}
} catch (Exception $e) {
} catch (\Error $e) {
var_dump($e->getMessage());
}

Expand Down
2 changes: 1 addition & 1 deletion ext/spl/tests/heap_009.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ function testForException( $heap )
{
foreach( $heap as &$item );
}
catch( RuntimeException $e )
catch( \Error $e )
{
echo $e->getMessage(),"\n";
}
Expand Down
2 changes: 1 addition & 1 deletion ext/spl/tests/iterator_069.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 9affbef

Please sign in to comment.