PHP :: Request #67949 :: DOMNodeList should implement ArrayAccess

 [2014-09-02 13:21 UTC] daverandom@php.net

Description:
------------
DOMNodeList should implement ArrayAccess. The write methods should either silently fail or throw a DOMException (probably the latter).

It would probably also be an idea to implement Countable at the same time, allowing for better interop between node lists and arrays of nodes.

Test script:
---------------
<?php

$html = <<<HTML
<div>data</div>
HTML;
$doc = new DOMDocument;
$doc->loadHTML($html);
var_dump($doc->getElementsByTagName('div')[0]->textContent);


Expected result:
----------------
string(4) "data"

Actual result:
--------------
Fatal error: Cannot use object of type DOMNodeList as array in...