From e5e3deff4eb295ed4775cc26e01260f672b47e61 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sun, 20 Jul 2025 22:59:55 +0200 Subject: [PATCH 1/2] Improve DomNode methods return type --- dom/dom_c.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/dom/dom_c.php b/dom/dom_c.php index c28e4c4ab..6a3fbaab4 100644 --- a/dom/dom_c.php +++ b/dom/dom_c.php @@ -162,14 +162,15 @@ class DOMNode /** * Adds a new child before a reference node * @link https://php.net/manual/en/domnode.insertbefore.php - * @param DOMNode $node

+ * @template TNode of DOMNode + * @param TNode $node

* The new node. *

* @param null|DOMNode $child [optional]

* The reference node. If not supplied, newnode is * appended to the children. *

- * @return DOMNode The inserted node. + * @return TNode|false The inserted node. */ public function insertBefore( DOMNode $node, @@ -179,35 +180,38 @@ public function insertBefore( /** * Replaces a child * @link https://php.net/manual/en/domnode.replacechild.php + * @template TNode of DOMNode * @param DOMNode $node

* The new node. It must be a member of the target document, i.e. * created by one of the DOMDocument->createXXX() methods or imported in * the document by . *

- * @param DOMNode $child

+ * @param TNode $child

* The old node. *

- * @return DOMNode|false The old node or false if an error occur. + * @return TNode|false The old node or false if an error occur. */ public function replaceChild(DOMNode $node, DOMNode $child) {} /** * Removes child from list of children * @link https://php.net/manual/en/domnode.removechild.php - * @param DOMNode $child

+ * @template TNode of DOMNode + * @param TNode $child

* The removed child. *

- * @return DOMNode If the child could be removed the functions returns the old child. + * @return TNode|false If the child could be removed the functions returns the old child. */ public function removeChild(DOMNode $child) {} /** * Adds new child at the end of the children * @link https://php.net/manual/en/domnode.appendchild.php - * @param DOMNode $node

+ * @template TNode of DOMNode + * @param TNode $node

* The appended child. *

- * @return DOMNode The node added. + * @return TNode|false The node added. */ public function appendChild(DOMNode $node) {} From 24209f4ce1e6cbe5dd76e553eaebb07eeda57094 Mon Sep 17 00:00:00 2001 From: Vincent Langlet Date: Sun, 20 Jul 2025 23:06:40 +0200 Subject: [PATCH 2/2] Add missing false --- dom/dom_c.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dom/dom_c.php b/dom/dom_c.php index 6a3fbaab4..50324f06a 100644 --- a/dom/dom_c.php +++ b/dom/dom_c.php @@ -230,7 +230,7 @@ public function hasChildNodes(): bool {} * Indicates whether to copy all descendant nodes. This parameter is * defaulted to false. *

- * @return static The cloned node. + * @return static|false The cloned node. */ public function cloneNode( #[PhpStormStubsElementAvailable(from: '5.3', to: '5.6')] $deep,