original_string: public function merge(SimpleXmlElement $element, $replace = true, $rule = null)
      {
          foreach ($element->children() as $name => $child) {
              $affected = null;
              $currentpath = $child->getPath();
              $action = $this->_getMergeRule($child, $affected, $rule);
  
              if ($action == self::MERGE_APPEND) {
                  $affected = $this->addChild($name, (string)$child);
              }
  
              if (!$affected instanceof SimpleXmlElement) {
                  continue;
              }
  
              $affected->mergeAttributes($child, $replace);
  
              if ($child->hasChildren()) {
                  $affected->merge($child, $replace, $rule);
                  continue;
              } else if ($replace) {
                  $affected[0] = (string)$child;
              }
          }
  
          return $this;
      }
code: public function merge(SimpleXmlElement $element, $replace = true, $rule = null)
      {
          foreach ($element->children() as $name => $child) {
              $affected = null;
              $currentpath = $child->getPath();
              $action = $this->_getMergeRule($child, $affected, $rule);
  
              if ($action == self::MERGE_APPEND) {
                  $affected = $this->addChild($name, (string)$child);
              }
  
              if (!$affected instanceof SimpleXmlElement) {
                  continue;
              }
  
              $affected->mergeAttributes($child, $replace);
  
              if ($child->hasChildren()) {
                  $affected->merge($child, $replace, $rule);
                  continue;
              } else if ($replace) {
                  $affected[0] = (string)$child;
              }
          }
  
          return $this;
      }
code_tokens: public function merge ( SimpleXmlElement $ element , $ replace = true , $ rule = null ) { foreach ( $ element -> children ( ) as $ name => $ child ) { $ affected = null ; $ currentpath = $ child -> getPath ( ) ; $ action = $ this -> _getMergeRule ( $ child , $ affected , $ rule ) ; if ( $ action == self :: MERGE_APPEND ) { $ affected = $ this -> addChild ( $ name , ( string ) $ child ) ; } if ( ! $ affected instanceof SimpleXmlElement ) { continue ; } $ affected -> mergeAttributes ( $ child , $ replace ) ; if ( $ child -> hasChildren ( ) ) { $ affected -> merge ( $ child , $ replace , $ rule ) ; continue ; } else if ( $ replace ) { $ affected [ 0 ] = ( string ) $ child ; } } return $ this ; }
docstring: merge another xml element into this one
  
  @param SimpleXmlElement $element
  @return string
docstring_tokens: merge another xml element into this one