mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Convert bounds exception in SplFixedArray to OutOfBoundsException instead of RuntimeException (#12383)
This commit is contained in:
@@ -34,6 +34,12 @@ PHP 8.4 UPGRADE NOTES
|
||||
This is no longer the case as a consequence of the bugfixes for GH-12192,
|
||||
GH-12208, #55098.
|
||||
|
||||
- SPL:
|
||||
. Out of bounds accesses in SplFixedArray now throw an exception of type
|
||||
OutOfBoundsException instead of RuntimeException. As OutOfBoundsException
|
||||
is a child class of RuntimeException, code that uses RuntimeException
|
||||
continues to function.
|
||||
|
||||
- Standard:
|
||||
. round() now validates the value of the $mode parameter and throws a ValueError
|
||||
for invalid modes. Previously invalid modes would have been interpreted as
|
||||
|
||||
@@ -376,8 +376,7 @@ static zval *spl_fixedarray_object_read_dimension_helper(spl_fixedarray_object *
|
||||
}
|
||||
|
||||
if (index < 0 || index >= intern->array.size) {
|
||||
// TODO Change error message and use OutOfBound SPL Exception?
|
||||
zend_throw_exception(spl_ce_RuntimeException, "Index invalid or out of range", 0);
|
||||
zend_throw_exception(spl_ce_OutOfBoundsException, "Index invalid or out of range", 0);
|
||||
return NULL;
|
||||
} else {
|
||||
return &intern->array.elements[index];
|
||||
@@ -425,8 +424,7 @@ static void spl_fixedarray_object_write_dimension_helper(spl_fixedarray_object *
|
||||
}
|
||||
|
||||
if (index < 0 || index >= intern->array.size) {
|
||||
// TODO Change error message and use OutOfBound SPL Exception?
|
||||
zend_throw_exception(spl_ce_RuntimeException, "Index invalid or out of range", 0);
|
||||
zend_throw_exception(spl_ce_OutOfBoundsException, "Index invalid or out of range", 0);
|
||||
return;
|
||||
} else {
|
||||
/* Fix #81429 */
|
||||
@@ -465,8 +463,7 @@ static void spl_fixedarray_object_unset_dimension_helper(spl_fixedarray_object *
|
||||
}
|
||||
|
||||
if (index < 0 || index >= intern->array.size) {
|
||||
// TODO Change error message and use OutOfBound SPL Exception?
|
||||
zend_throw_exception(spl_ce_RuntimeException, "Index invalid or out of range", 0);
|
||||
zend_throw_exception(spl_ce_OutOfBoundsException, "Index invalid or out of range", 0);
|
||||
return;
|
||||
} else {
|
||||
zval_ptr_dtor(&(intern->array.elements[index]));
|
||||
|
||||
@@ -45,9 +45,9 @@ $a[0] = "valueNew";
|
||||
var_dump($b[0]);
|
||||
?>
|
||||
--EXPECT--
|
||||
RuntimeException: Index invalid or out of range
|
||||
OutOfBoundsException: Index invalid or out of range
|
||||
TypeError: Cannot access offset of type string on SplFixedArray
|
||||
RuntimeException: Index invalid or out of range
|
||||
OutOfBoundsException: Index invalid or out of range
|
||||
string(6) "value0"
|
||||
string(6) "value2"
|
||||
string(6) "value3"
|
||||
|
||||
@@ -69,11 +69,11 @@ var_dump(count($a), $a->getSize(), count($a) == $a->getSize());
|
||||
?>
|
||||
--EXPECT--
|
||||
A::offsetSet
|
||||
RuntimeException: Index invalid or out of range
|
||||
OutOfBoundsException: Index invalid or out of range
|
||||
A::offsetGet
|
||||
TypeError: Cannot access offset of type string on SplFixedArray
|
||||
A::offsetUnset
|
||||
RuntimeException: Index invalid or out of range
|
||||
OutOfBoundsException: Index invalid or out of range
|
||||
A::offsetSet
|
||||
A::offsetSet
|
||||
A::offsetSet
|
||||
|
||||
Reference in New Issue
Block a user