original_string: public function expand(DOMNode $basenode = null)
      {
          if (null === $basenode) {
              $basenode = new DomDocument();
          }
  
          if ($basenode instanceof DOMDocument) {
              $doc = $basenode;
          } else {
              $doc = $basenode->ownerDocument;
          }
  
          if (false === $node = $this->reader->expand($basenode)) {
              throw new BadMethodCallException('Unable to expand node.');
          }
  
          if ($node->ownerDocument !== $doc) {
              $node = $doc->importNode($node, true);
          }
  
          return $node;
      }
code: public function expand(DOMNode $basenode = null)
      {
          if (null === $basenode) {
              $basenode = new DomDocument();
          }
  
          if ($basenode instanceof DOMDocument) {
              $doc = $basenode;
          } else {
              $doc = $basenode->ownerDocument;
          }
  
          if (false === $node = $this->reader->expand($basenode)) {
              throw new BadMethodCallException('Unable to expand node.');
          }
  
          if ($node->ownerDocument !== $doc) {
              $node = $doc->importNode($node, true);
          }
  
          return $node;
      }
code_tokens: public function expand ( DOMNode $ basenode = null ) { if ( null === $ basenode ) { $ basenode = new DomDocument ( ) ; } if ( $ basenode instanceof DOMDocument ) { $ doc = $ basenode ; } else { $ doc = $ basenode -> ownerDocument ; } if ( false === $ node = $ this -> reader -> expand ( $ basenode ) ) { throw new BadMethodCallException ( 'Unable to expand node.' ) ; } if ( $ node -> ownerDocument !== $ doc ) { $ node = $ doc -> importNode ( $ node , true ) ; } return $ node ; }
docstring: XMLReader expand node and import it into a DOMNode with a DOMDocument
  
  This is for example useful for DOMDocument::saveXML() @see readOuterXml
  or getting a SimpleXMLElement out of it @see getSimpleXMLElement
  
  @throws BadMethodCallException
  @param DOMNode $basenode
  @return DOMNode
docstring_tokens: XMLReader expand node and import it into a DOMNode with a DOMDocument