From af65ff8551e0dc570b654d16c2e0cf4866d40a93 Mon Sep 17 00:00:00 2001 From: Markus Staab Date: Thu, 20 Nov 2025 10:38:02 +0100 Subject: [PATCH] Remove getElementsByTagNameNS() for cases which can never find a element --- src/Report/Xml/Project.php | 19 ++++++------------- src/Report/Xml/Report.php | 19 ++++++------------- 2 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/Report/Xml/Project.php b/src/Report/Xml/Project.php index 160170320..8b9e031c9 100644 --- a/src/Report/Xml/Project.php +++ b/src/Report/Xml/Project.php @@ -63,19 +63,12 @@ public function buildInformation(): BuildInformation public function tests(): Tests { - $testsNode = $this->contextNode()->getElementsByTagNameNS( - Facade::XML_NAMESPACE, - 'tests', - )->item(0); - - if ($testsNode === null) { - $testsNode = $this->contextNode()->appendChild( - $this->dom()->createElementNS( - Facade::XML_NAMESPACE, - 'tests', - ), - ); - } + $testsNode = $this->contextNode()->appendChild( + $this->dom()->createElementNS( + Facade::XML_NAMESPACE, + 'tests', + ), + ); assert($testsNode instanceof DOMElement); diff --git a/src/Report/Xml/Report.php b/src/Report/Xml/Report.php index 14d2d5a06..6f4400a02 100644 --- a/src/Report/Xml/Report.php +++ b/src/Report/Xml/Report.php @@ -119,19 +119,12 @@ public function traitObject( public function source(): Source { - $source = $this->contextNode()->getElementsByTagNameNS( - Facade::XML_NAMESPACE, - 'source', - )->item(0); - - if ($source === null) { - $source = $this->contextNode()->appendChild( - $this->dom()->createElementNS( - Facade::XML_NAMESPACE, - 'source', - ), - ); - } + $source = $this->contextNode()->appendChild( + $this->dom()->createElementNS( + Facade::XML_NAMESPACE, + 'source', + ), + ); assert($source instanceof DOMElement);