php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #67949 DOMNodeList should implement ArrayAccess
Submitted: 2014-09-02 13:21 UTC Modified: 2014-11-17 14:46 UTC
Votes:2
Avg. Score:4.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: daverandom@php.net Assigned: fmargaine (profile)
Status: Closed Package: DOM XML related
PHP Version: Irrelevant OS: Any
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: daverandom@php.net
New email:
PHP Version: OS:

 

 [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...

Patches

Add a Patch

Pull Requests

Pull requests:

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-24 20:08 UTC] fmargaine@php.net
-Assigned To: +Assigned To: fmargaine
 [2014-10-09 09:02 UTC] fmargaine@php.net
PHP-5.6: https://github.com/php/php-src/commit/9469db93110b2185f019da0dd66d3537c1a4b7a4

master PR (https://github.com/php/php-src/pull/842) still pending, but shouldn't have any issue since the 5.6 PR was merged.
 [2014-11-17 14:46 UTC] fmargaine@php.net
-Status: Assigned +Status: Closed
 [2014-11-17 14:46 UTC] fmargaine@php.net
Released in 5.6.3
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Wed Jun 03 13:01:25 2020 UTC