doc-en icon indicating copy to clipboard operation
doc-en copied to clipboard

Wrong Example in SplFixedArray docs

Open abdelrahman-gado opened this issue 6 months ago • 4 comments

From manual page: https://php.net/class.splfixedarray


In the example of SplFixedArray Example #1 SplFixedArray usage example, you state that the following code will give RuntimeException but what it is actually throws is TypeError. So, the catch part will never executed.

// The following lines throw a RuntimeException: Index invalid or out of range
try {
    var_dump($array["non-numeric"]);
} catch(RuntimeException $re) {
    echo "RuntimeException: ".$re->getMessage()."\n";
}

image

abdelrahman-gado avatar Aug 24 '24 02:08 abdelrahman-gado