original_string: protected function setNode(\DOMElement $node)
      {
          $this->button = $node;
          if ('button' === $node->nodeName || ('input' === $node->nodeName && \in_array(strtolower($node->getAttribute('type')), ['submit', 'button', 'image']))) {
              if ($node->hasAttribute('form')) {
                  // if the node has the HTML5-compliant 'form' attribute, use it
                  $formId = $node->getAttribute('form');
                  $form = $node->ownerDocument->getElementById($formId);
                  if (null === $form) {
                      throw new \LogicException(sprintf('The selected node has an invalid form attribute (%s).', $formId));
                  }
                  $this->node = $form;
  
                  return;
              }
              // we loop until we find a form ancestor
              do {
                  if (null === $node = $node->parentNode) {
                      throw new \LogicException('The selected node does not have a form ancestor.');
                  }
              } while ('form' !== $node->nodeName);
          } elseif ('form' !== $node->nodeName) {
              throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName));
          }
  
          $this->node = $node;
      }
code: protected function setNode(\DOMElement $node)
      {
          $this->button = $node;
          if ('button' === $node->nodeName || ('input' === $node->nodeName && \in_array(strtolower($node->getAttribute('type')), ['submit', 'button', 'image']))) {
              if ($node->hasAttribute('form')) {
                  // if the node has the HTML5-compliant 'form' attribute, use it
                  $formId = $node->getAttribute('form');
                  $form = $node->ownerDocument->getElementById($formId);
                  if (null === $form) {
                      throw new \LogicException(sprintf('The selected node has an invalid form attribute (%s).', $formId));
                  }
                  $this->node = $form;
  
                  return;
              }
              // we loop until we find a form ancestor
              do {
                  if (null === $node = $node->parentNode) {
                      throw new \LogicException('The selected node does not have a form ancestor.');
                  }
              } while ('form' !== $node->nodeName);
          } elseif ('form' !== $node->nodeName) {
              throw new \LogicException(sprintf('Unable to submit on a "%s" tag.', $node->nodeName));
          }
  
          $this->node = $node;
      }
code_tokens: protected function setNode ( \ DOMElement $ node ) { $ this -> button = $ node ; if ( 'button' === $ node -> nodeName || ( 'input' === $ node -> nodeName && \ in_array ( strtolower ( $ node -> getAttribute ( 'type' ) ) , [ 'submit' , 'button' , 'image' ] ) ) ) { if ( $ node -> hasAttribute ( 'form' ) ) { // if the node has the HTML5-compliant 'form' attribute, use it $ formId = $ node -> getAttribute ( 'form' ) ; $ form = $ node -> ownerDocument -> getElementById ( $ formId ) ; if ( null === $ form ) { throw new \ LogicException ( sprintf ( 'The selected node has an invalid form attribute (%s).' , $ formId ) ) ; } $ this -> node = $ form ; return ; } // we loop until we find a form ancestor do { if ( null === $ node = $ node -> parentNode ) { throw new \ LogicException ( 'The selected node does not have a form ancestor.' ) ; } } while ( 'form' !== $ node -> nodeName ) ; } elseif ( 'form' !== $ node -> nodeName ) { throw new \ LogicException ( sprintf ( 'Unable to submit on a "%s" tag.' , $ node -> nodeName ) ) ; } $ this -> node = $ node ; }
docstring: Sets the node for the form.
  
  Expects a 'submit' button \DOMElement and finds the corresponding form element, or the form element itself.
  
  @throws \LogicException If given node is not a button or input or does not have a form ancestor
docstring_tokens: Sets the node for the form .