Skip to content

Commit

Permalink
Fix "It is recommended not to use reserved keyword "parent"".
Browse files Browse the repository at this point in the history
  • Loading branch information
remcotolsma committed Oct 11, 2023
1 parent cf1a258 commit 36fbc01
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/XML/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,34 +113,34 @@ public function set_create_date( DateTimeImmutable $create_date ) {
* Create and add an element with the specified name and value to the specified parent
*
* @param DOMDocument $document Document.
* @param DOMNode $parent Parent.
* @param DOMNode $element Parent.
* @param string $name Element name.
* @param string|null $value Element text value.
* @return \DOMElement
*/
public static function add_element( DOMDocument $document, DOMNode $parent, $name, $value = null ) {
$element = $document->createElement( $name );
public static function add_element( DOMDocument $document, DOMNode $element, $name, $value = null ) {
$child = $document->createElement( $name );

if ( null !== $value ) {
$element->appendChild( new DOMText( $value ) );
$child->appendChild( new DOMText( $value ) );
}

$parent->appendChild( $element );
$element->appendChild( $child );

return $element;
return $child;
}

/**
* Add the specified elements to the parent node
*
* @param DOMDocument $document Document.
* @param DOMNode $parent Parent.
* @param array<string, string|null> $elements Elements to add.
* @param DOMNode $element Parent.
* @param array<string, string|null> $children Elements to add.
* @return void
*/
public static function add_elements( DOMDocument $document, DOMNode $parent, array $elements = [] ) {
foreach ( $elements as $name => $value ) {
self::add_element( $document, $parent, $name, $value );
public static function add_elements( DOMDocument $document, DOMNode $element, array $children = [] ) {
foreach ( $children as $name => $value ) {
self::add_element( $document, $element, $name, $value );
}
}
}

0 comments on commit 36fbc01

Please sign in to comment.