Skip to content

Commit 9affbef

Browse files
committed
Use normal error in SPL for 'An iterator cannot be used with foreach by reference'
1 parent 4fc7026 commit 9affbef

12 files changed

+14
-14
lines changed

ext/spl/spl_array.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1144,7 +1144,7 @@ zend_object_iterator *spl_array_get_iterator(zend_class_entry *ce, zval *object,
11441144
spl_array_object *array_object = Z_SPLARRAY_P(object);
11451145

11461146
if (by_ref && (array_object->ar_flags & SPL_ARRAY_OVERLOADED_CURRENT)) {
1147-
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0);
1147+
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
11481148
return NULL;
11491149
}
11501150

ext/spl/spl_directory.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1612,7 +1612,7 @@ zend_object_iterator *spl_filesystem_dir_get_iterator(zend_class_entry *ce, zval
16121612
spl_filesystem_object *dir_object;
16131613

16141614
if (by_ref) {
1615-
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0);
1615+
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
16161616
return NULL;
16171617
}
16181618
dir_object = Z_SPLFILESYSTEM_P(object);
@@ -1819,7 +1819,7 @@ zend_object_iterator *spl_filesystem_tree_get_iterator(zend_class_entry *ce, zva
18191819
spl_filesystem_object *dir_object;
18201820

18211821
if (by_ref) {
1822-
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0);
1822+
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
18231823
return NULL;
18241824
}
18251825
dir_object = Z_SPLFILESYSTEM_P(object);

ext/spl/spl_dllist.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ zend_object_iterator *spl_dllist_get_iterator(zend_class_entry *ce, zval *object
13081308
spl_dllist_object *dllist_object = Z_SPLDLLIST_P(object);
13091309

13101310
if (by_ref) {
1311-
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0);
1311+
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
13121312
return NULL;
13131313
}
13141314

ext/spl/spl_fixedarray.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,7 @@ zend_object_iterator *spl_fixedarray_get_iterator(zend_class_entry *ce, zval *ob
955955
spl_fixedarray_it *iterator;
956956

957957
if (by_ref) {
958-
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0);
958+
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
959959
return NULL;
960960
}
961961

ext/spl/spl_heap.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1066,7 +1066,7 @@ zend_object_iterator *spl_heap_get_iterator(zend_class_entry *ce, zval *object,
10661066
spl_heap_object *heap_object = Z_SPLHEAP_P(object);
10671067

10681068
if (by_ref) {
1069-
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0);
1069+
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
10701070
return NULL;
10711071
}
10721072

@@ -1091,7 +1091,7 @@ zend_object_iterator *spl_pqueue_get_iterator(zend_class_entry *ce, zval *object
10911091
spl_heap_object *heap_object = Z_SPLHEAP_P(object);
10921092

10931093
if (by_ref) {
1094-
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0);
1094+
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
10951095
return NULL;
10961096
}
10971097

ext/spl/spl_iterators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ static zend_object_iterator *spl_recursive_it_get_iterator(zend_class_entry *ce,
448448
spl_recursive_it_object *object;
449449

450450
if (by_ref) {
451-
zend_throw_exception(spl_ce_RuntimeException, "An iterator cannot be used with foreach by reference", 0);
451+
zend_throw_error(NULL, "An iterator cannot be used with foreach by reference");
452452
return NULL;
453453
}
454454
iterator = emalloc(sizeof(spl_recursive_it_iterator));

ext/spl/tests/DirectoryIterator_by_reference.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ foreach( $it as &$file ) {
1111
}
1212
?>
1313
--EXPECTF--
14-
Fatal error: Uncaught RuntimeException: An iterator cannot be used with foreach by reference in %s:%d
14+
Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in %s:%d
1515
Stack trace:
1616
#0 {main}
1717
thrown in %s on line %d

ext/spl/tests/SPLDoublyLinkedList_iterate_by_reference.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ try {
1717
$value *= $value;
1818
echo $value, PHP_EOL;
1919
}
20-
} catch (Exception $e) {
20+
} catch (\Error $e) {
2121
echo $e->getMessage(), PHP_EOL;
2222
}
2323

ext/spl/tests/array_019.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ int(2)
2626
int(3)
2727
int(4)
2828

29-
Fatal error: Uncaught RuntimeException: An iterator cannot be used with foreach by reference in %s:%d
29+
Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in %s:%d
3030
Stack trace:
3131
#0 {main}
3232
thrown in %s on line %d

ext/spl/tests/fixedarray_021.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ try {
4646
foreach ($e as $k=>&$v) {
4747
var_dump($v);
4848
}
49-
} catch (Exception $e) {
49+
} catch (\Error $e) {
5050
var_dump($e->getMessage());
5151
}
5252

ext/spl/tests/heap_009.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ function testForException( $heap )
1111
{
1212
foreach( $heap as &$item );
1313
}
14-
catch( RuntimeException $e )
14+
catch( \Error $e )
1515
{
1616
echo $e->getMessage(),"\n";
1717
}

ext/spl/tests/iterator_069.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ foreach ($recItIt as &$val) echo "$val\n";
1414

1515
?>
1616
--EXPECTF--
17-
Fatal error: Uncaught RuntimeException: An iterator cannot be used with foreach by reference in %s:%d
17+
Fatal error: Uncaught Error: An iterator cannot be used with foreach by reference in %s:%d
1818
Stack trace:
1919
#0 {main}
2020
thrown in %s on line %d

0 commit comments

Comments
 (0)