|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79271 DOMDocumentType extends DOMNode, but doesn't provide $childNodes as DOMNodeList
Submitted: 2020-02-13 17:19 UTC Modified: 2020-02-17 08:13 UTC
From: ca at lsp dot net Assigned: cmb (profile)
Status: Closed Package: DOM XML related
PHP Version: 7.3.14 OS: Windows
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: ca at lsp dot net
New email:
PHP Version: OS:


 [2020-02-13 17:19 UTC] ca at lsp dot net
From manual page:

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.


Test script:
$dom = new DOMImplementation();
$type = $dom->createDocumentType('html');
echo get_class($type->childNodes);

Expected result:

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


Add a Patch

Pull Requests

Pull requests:

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-13 19:04 UTC]
-Type: Documentation Problem +Type: Bug
 [2020-02-13 19:04 UTC]
I can't find anything in the spec that says a DocumentType has different behavior from Node regarding its children.

As such I think this is a code bug: ->childNodes should be an (empty) DOMNodeList.
 [2020-02-14 10:09 UTC]
The following pull request has been associated:

Patch Name: Fix #79271: DOMDocumentType::$childNodes is NULL
On GitHub:
 [2020-02-17 08:11 UTC]
Automatic comment on behalf of
Log: Fix #79271: DOMDocumentType::$childNodes is NULL
 [2020-02-17 08:11 UTC]
-Status: Open +Status: Closed
 [2020-02-17 08:13 UTC]
-Assigned To: +Assigned To: cmb
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 11:01:29 2024 UTC