Req #67949 [NEW]: DOMNodeList should implement ArrayAccess

From: Date: Tue, 02 Sep 2014 13:21:38 +0000
Subject: Req #67949 [NEW]: DOMNodeList should implement ArrayAccess
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-187384@lists.php.net to get a copy of this message
From: daverandom Operating system: Any PHP version: Irrelevant Package: DOM XML related Bug Type: Feature/Change Request Bug description:DOMNodeList should implement ArrayAccess 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... -- Edit bug report at https://bugs.php.net/bug.php?id=67949&edit=1 --

« previous php.bugs (#187384) next »