From afc479ff98772dda6689f967fb643301e645a298 Mon Sep 17 00:00:00 2001 From: Bruce Weirdan Date: Tue, 1 Aug 2023 11:36:22 +0200 Subject: [PATCH] Fixed `DOMDocument::load*` signatures Prior to 8.0 those methods could be called statically, returning a `DOMDocument` instance. In 8.0 and above they no longer can be. --- dictionaries/CallMap.php | 4 ++-- dictionaries/CallMap_80_delta.php | 16 ++++++++++++++++ dictionaries/CallMap_historical.php | 4 ++-- stubs/extensions/dom.phpstub | 8 ++++---- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/dictionaries/CallMap.php b/dictionaries/CallMap.php index 7d8c477b1a1..067206c9289 100644 --- a/dictionaries/CallMap.php +++ b/dictionaries/CallMap.php @@ -1679,10 +1679,10 @@ 'DOMDocument::getElementsByTagName' => ['DOMNodeList', 'qualifiedName'=>'string'], 'DOMDocument::getElementsByTagNameNS' => ['DOMNodeList', 'namespace'=>'?string', 'localName'=>'string'], 'DOMDocument::importNode' => ['DOMNode|false', 'node'=>'DOMNode', 'deep='=>'bool'], -'DOMDocument::load' => ['DOMDocument|bool', 'filename'=>'string', 'options='=>'int'], +'DOMDocument::load' => ['bool', 'filename'=>'string', 'options='=>'int'], 'DOMDocument::loadHTML' => ['bool', 'source'=>'non-empty-string', 'options='=>'int'], 'DOMDocument::loadHTMLFile' => ['bool', 'filename'=>'string', 'options='=>'int'], -'DOMDocument::loadXML' => ['DOMDocument|bool', 'source'=>'non-empty-string', 'options='=>'int'], +'DOMDocument::loadXML' => ['bool', 'source'=>'non-empty-string', 'options='=>'int'], 'DOMDocument::normalizeDocument' => ['void'], 'DOMDocument::registerNodeClass' => ['bool', 'baseClass'=>'string', 'extendedClass'=>'?string'], 'DOMDocument::relaxNGValidate' => ['bool', 'filename'=>'string'], diff --git a/dictionaries/CallMap_80_delta.php b/dictionaries/CallMap_80_delta.php index 134b79a0ce6..1f838e44c4d 100644 --- a/dictionaries/CallMap_80_delta.php +++ b/dictionaries/CallMap_80_delta.php @@ -100,6 +100,22 @@ 'old' => ['DOMNodeList', 'namespace'=>'string', 'localName'=>'string'], 'new' => ['DOMNodeList', 'namespace'=>'?string', 'localName'=>'string'], ], + 'DOMDocument::load' => [ + 'old' => ['DOMDocument|bool', 'filename'=>'string', 'options='=>'int'], + 'new' => ['bool', 'filename'=>'string', 'options='=>'int'], + ], + 'DOMDocument::loadXML' => [ + 'old' => ['DOMDocument|bool', 'source'=>'non-empty-string', 'options='=>'int'], + 'new' => ['bool', 'source'=>'non-empty-string', 'options='=>'int'], + ], + 'DOMDocument::loadHTML' => [ + 'old' => ['DOMDocument|bool', 'source'=>'non-empty-string', 'options='=>'int'], + 'old' => ['bool', 'source'=>'non-empty-string', 'options='=>'int'], + ], + 'DOMDocument::loadHTMLFile' => [ + 'old' => ['DOMDocument|bool', 'filename'=>'string', 'options='=>'int'], + 'new' => ['bool', 'filename'=>'string', 'options='=>'int'], + ], 'DOMImplementation::createDocument' => [ 'old' => ['DOMDocument|false', 'namespace='=>'string', 'qualifiedName='=>'string', 'doctype='=>'DOMDocumentType'], 'new' => ['DOMDocument|false', 'namespace='=>'?string', 'qualifiedName='=>'string', 'doctype='=>'?DOMDocumentType'], diff --git a/dictionaries/CallMap_historical.php b/dictionaries/CallMap_historical.php index d20efff9f0f..36b4fe0373d 100644 --- a/dictionaries/CallMap_historical.php +++ b/dictionaries/CallMap_historical.php @@ -733,8 +733,8 @@ 'DOMDocument::getElementsByTagNameNS' => ['DOMNodeList', 'namespace'=>'string', 'localName'=>'string'], 'DOMDocument::importNode' => ['DOMNode|false', 'node'=>'DOMNode', 'deep='=>'bool'], 'DOMDocument::load' => ['DOMDocument|bool', 'filename'=>'string', 'options='=>'int'], - 'DOMDocument::loadHTML' => ['bool', 'source'=>'non-empty-string', 'options='=>'int'], - 'DOMDocument::loadHTMLFile' => ['bool', 'filename'=>'string', 'options='=>'int'], + 'DOMDocument::loadHTML' => ['DOMDocument|bool', 'source'=>'non-empty-string', 'options='=>'int'], + 'DOMDocument::loadHTMLFile' => ['DOMDocument|bool', 'filename'=>'string', 'options='=>'int'], 'DOMDocument::loadXML' => ['DOMDocument|bool', 'source'=>'non-empty-string', 'options='=>'int'], 'DOMDocument::normalizeDocument' => ['void'], 'DOMDocument::registerNodeClass' => ['bool', 'baseClass'=>'string', 'extendedClass'=>'?string'], diff --git a/stubs/extensions/dom.phpstub b/stubs/extensions/dom.phpstub index 5b42368ce98..f52153787d6 100644 --- a/stubs/extensions/dom.phpstub +++ b/stubs/extensions/dom.phpstub @@ -471,13 +471,13 @@ class DOMDocument extends DOMNode implements DOMParentNode public function importNode(DOMNode $node, bool $deep = false) {} /** - * @return DOMDocument|false + * @return bool * @psalm-ignore-falsable-return **/ public function load(string $filename, int $options = 0) {} /** - * @return DOMDocument|false + * @return bool * @psalm-ignore-falsable-return */ public function loadXML(string $source, int $options = 0) {} @@ -492,10 +492,10 @@ class DOMDocument extends DOMNode implements DOMParentNode */ public function save(string $filename, int $options = 0) {} - /** @return DOMDocument|bool */ + /** @return bool */ public function loadHTML(string $source, int $options = 0) {} - /** @return DOMDocument|bool */ + /** @return bool */ public function loadHTMLFile(string $filename, int $options = 0) {} /**