Doc->Bug #79271 [Opn]: DOMDocumentType extends DOMNode, but doesn't provide $childNodes as DOMNodeList

From: Date: Thu, 13 Feb 2020 19:04:13 +0000
Subject: Doc->Bug #79271 [Opn]: DOMDocumentType extends DOMNode, but doesn't provide $childNodes as DOMNodeList
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225569@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 Updated by: requinix@php.net Reported by: ca at lsp dot net Summary: DOMDocumentType extends DOMNode, but doesn't provide $childNodes as DOMNodeList Status: Open -Type: Documentation Problem +Type: Bug Package: DOM XML related Operating System: Windows PHP Version: 7.3.14 Block user comment: N Private report: N New Comment: 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. Previous Comments: ------------------------------------------------------------------------ [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

« previous php.bugs (#225569) next »