From 63a61ddd62e5ef323f0c10e425c47f041c046873 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20Bate=C4=8Dko?= Date: Wed, 24 Jul 2019 04:53:31 +0200 Subject: [PATCH] Improve DOM extension types (#1965) * Improve DOM extension types * fixup! Improve DOM extension types --- src/Psalm/Internal/CallMap.php | 6 +++--- src/Psalm/Internal/PropertyMap.php | 17 ++++++++++------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/Psalm/Internal/CallMap.php b/src/Psalm/Internal/CallMap.php index 4fc85d407ed..b802f2707c5 100644 --- a/src/Psalm/Internal/CallMap.php +++ b/src/Psalm/Internal/CallMap.php @@ -2165,7 +2165,7 @@ 'DOMNode::getNodePath' => ['?string'], 'DOMNode::hasAttributes' => ['bool'], 'DOMNode::hasChildNodes' => ['bool'], -'DOMNode::insertBefore' => ['DOMNode', 'newnode'=>'DOMNode', 'refnode='=>'DOMNode'], +'DOMNode::insertBefore' => ['DOMNode', 'newnode'=>'DOMNode', 'refnode='=>'DOMNode|null'], 'DOMNode::isDefaultNamespace' => ['bool', 'namespaceuri'=>'string'], 'DOMNode::isSameNode' => ['bool', 'node'=>'DOMNode'], 'DOMNode::isSupported' => ['bool', 'feature'=>'string', 'version'=>'string'], @@ -2193,8 +2193,8 @@ 'domxml_xslt_stylesheet_file' => ['DomXsltStylesheet', 'xsl_file'=>'string'], 'domxml_xslt_version' => ['int'], 'DOMXPath::__construct' => ['void', 'doc'=>'DOMDocument'], -'DOMXPath::evaluate' => ['mixed', 'expression'=>'string', 'contextnode='=>'DOMNode', 'registernodens='=>'bool'], -'DOMXPath::query' => ['false|DOMNodeList', 'expression'=>'string', 'contextnode='=>'DOMNode', 'registernodens='=>'bool'], +'DOMXPath::evaluate' => ['mixed', 'expression'=>'string', 'contextnode='=>'DOMNode|null', 'registernodens='=>'bool'], +'DOMXPath::query' => ['false|DOMNodeList', 'expression'=>'string', 'contextnode='=>'DOMNode|null', 'registernodens='=>'bool'], 'DOMXPath::registerNamespace' => ['bool', 'prefix'=>'string', 'namespaceuri'=>'string'], 'DOMXPath::registerPhpFunctions' => ['void', 'restrict='=>'mixed'], 'DomXsltStylesheet::process' => ['DomDocument', 'xml_doc'=>'DOMDocument', 'xslt_params='=>'array', 'is_xpath_param='=>'bool', 'profile_filename='=>'string'], diff --git a/src/Psalm/Internal/PropertyMap.php b/src/Psalm/Internal/PropertyMap.php index e092d41bf92..d3c84aa10f3 100644 --- a/src/Psalm/Internal/PropertyMap.php +++ b/src/Psalm/Internal/PropertyMap.php @@ -199,6 +199,8 @@ 'xmlEncoding' => 'string', 'xmlStandalone' => 'bool', 'xmlVersion' => 'string', + 'ownerDocument' => 'null', + 'parentNode' => 'null', ], 'libxmlerror' => [ 'level' => 'int', @@ -266,6 +268,7 @@ 'domelement' => [ 'schemaTypeInfo' => 'bool', 'tagName' => 'string', + 'attributes' => 'DOMNamedNodeMap', ], 'tidynode' => [ 'value' => 'string', @@ -319,16 +322,16 @@ 'nodeType' => 'int', 'parentNode' => 'DOMNode', 'childNodes' => 'DOMNodeList', - 'firstChild' => 'DOMNode', - 'lastChild' => 'DOMNode', - 'previousSibling' => 'DOMNode', - 'nextSibling' => 'DOMNode', - 'attributes' => 'DOMNamedNodeMap', + 'firstChild' => 'DOMNode|null', + 'lastChild' => 'DOMNode|null', + 'previousSibling' => 'DOMNode|null', + 'nextSibling' => 'DOMNode|null', + 'attributes' => 'null', 'ownerDocument' => 'DOMDocument', - 'namespaceURI' => 'string', + 'namespaceURI' => 'string|null', 'prefix' => 'string', 'localName' => 'string', - 'baseURI' => 'string', + 'baseURI' => 'string|null', 'textContent' => 'string', ], 'domattr' => [