Bug #79271 [PATCH]: DOMDocumentType extends DOMNode, but doesn't provide $childNodes as DOMNodeList
| From: | cmb@php.net | Date: | Fri, 14 Feb 2020 10:09:35 +0000 |
| Subject: | Bug #79271 [PATCH]: DOMDocumentType extends DOMNode, but doesn't provide $childNodes as DOMNodeList | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-225575@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=79271&edit=1
ID: 79271
Patch added by: cmb@php.net
Reported by: ca at lsp dot net
Summary: DOMDocumentType extends DOMNode, but doesn't provide
$childNodes as DOMNodeList
Status: Open
Type: Bug
Package: DOM XML related
Operating System: Windows
PHP Version: 7.3.14
Block user comment: N
Private report: N
New Comment:
The following pull request has been associated:
Patch Name: Fix #79271: DOMDocumentType::$childNodes is NULL
On GitHub: https://github.com/php/php-src/pull/5180
Patch: https://github.com/php/php-src/pull/5180.patch
Previous Comments:
------------------------------------------------------------------------
[2020-02-13 19:04:13] requinix@php.net
I can't find anything in the spec that says a DocumentType has different behavior from Node
regarding its children.
https://dom.spec.whatwg.org/
As such I think this is a code bug: ->childNodes should be an (empty) DOMNodeList.
------------------------------------------------------------------------
[2020-02-13 17:19:36] ca at lsp dot net
Description:
------------
---
From manual page: https://php.net/class.domdocumenttype
---
According to the
DOMNode documentation [1], the $childNodes property
always refers to a DOMNodeList.
However, DOMDocumentType extends DOMNode, but doesn't provide the
property nor supports hasChildNodes().
This means that the following test script causes a Notice.
[1] https://www.php.net/class.domnode.php
Test script:
---------------
$dom = new DOMImplementation();
$type = $dom->createDocumentType('html');
echo get_class($type->childNodes);
Expected result:
----------------
DOMNodeList
Actual result:
--------------
Warning: get_class() expects parameter 1 to be object, null given in test.php on line 5
Call Stack:
0.0075 398976 1. {main}() test.php:0
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=79271&edit=1