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

From: Date: Mon, 17 Feb 2020 08:11:52 +0000
Subject: Bug #79271 [Opn->Csd]: DOMDocumentType extends DOMNode, but doesn't provide $childNodes as DOMNodeList
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225604@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: cmb@php.net Reported by: ca at lsp dot net Summary: DOMDocumentType extends DOMNode, but doesn't provide $childNodes as DOMNodeList -Status: Open +Status: Closed Type: Bug Package: DOM XML related Operating System: Windows PHP Version: 7.3.14 Block user comment: N Private report: N New Comment: Automatic comment on behalf of cmbecker69@gmx.de Revision: http://git.php.net/?p=php-src.git;a=commit;h=09669411309b5c18c48b550d89b34e78983118cd Log: Fix #79271: DOMDocumentType::$childNodes is NULL Previous Comments: ------------------------------------------------------------------------ [2020-02-14 10:09:34] cmb@php.net 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 ------------------------------------------------------------------------ [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

« previous php.bugs (#225604) next »