Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 29 additions & 13 deletions reference/spl/splfixedarray.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- EN-Revision: 17ebcd2ea14b405b781bd93aea6fa7219b6e29ae Maintainer: andresdzphp Status: ready -->
<!-- Reviewed: yes Maintainer: seros -->
<!-- EN-Revision: a833060594749e44ff296fee01fd587d6395cff7 Maintainer: andresdzphp Status: ready -->
<reference xml:id="class.splfixedarray" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>La clase SplFixedArray</title>
<titleabbrev>SplFixedArray</titleabbrev>
Expand Down Expand Up @@ -88,6 +87,14 @@
a <classname>SplFixedArray</classname>.
</entry>
</row>
<row>
<entry>8.1.0</entry>
<entry>
El uso de una clave no entera en un <classname>SplFixedArray</classname>
ahora lanza un <exceptionname>TypeError</exceptionname> en lugar de una
<exceptionname>RuntimeException</exceptionname>.
</entry>
</row>
<row>
<entry>8.1.0</entry>
<entry>
Expand Down Expand Up @@ -136,23 +143,25 @@
// Reducir el tamaño de un array a 2
$array->setSize(2);

// Las siguientes líneas lanzan una RuntimeException: Index invalid or out of range (Índice inválido o fuera de rango)
// Los dos bloques siguientes lanzan una RuntimeException: Index invalid or out of range (Índice inválido o fuera de rango)
try {
var_dump($array["non-numeric"]);
} catch(RuntimeException $re) {
echo "RuntimeException: ".$re->getMessage()."\n";
var_dump($array[-1]);
} catch(RuntimeException $e) {
echo "RuntimeException: ".$e->getMessage()."\n";
}

try {
var_dump($array[-1]);
} catch(RuntimeException $re) {
echo "RuntimeException: ".$re->getMessage()."\n";
var_dump($array[5]);
} catch(RuntimeException $e) {
echo "RuntimeException: ".$e->getMessage()."\n";
}

// A partir de PHP 8.1.0, el uso de una clave no entera lanza un TypeError.
// Antes de PHP 8.1.0, se lanzaba una RuntimeException en su lugar.
try {
var_dump($array[5]);
} catch(RuntimeException $re) {
echo "RuntimeException: ".$re->getMessage()."\n";
var_dump($array["non-numeric"]);
} catch(TypeError $e) {
echo "TypeError: ".$e->getMessage()."\n";
}
?>
]]>
Expand All @@ -165,11 +174,18 @@
string(3) "foo"
RuntimeException: Index invalid or out of range
RuntimeException: Index invalid or out of range
RuntimeException: Index invalid or out of range
TypeError: Illegal offset type
]]>
</screen>
</example>
</para>
<note>
<simpara>
Antes de PHP 8.1.0, acceder a un <classname>SplFixedArray</classname> con
una clave no entera lanzaba una <exceptionname>RuntimeException</exceptionname>
en lugar de un <exceptionname>TypeError</exceptionname>.
</simpara>
</note>
</section>
<!-- }}} -->

Expand Down
Loading