code: private function findComparisonEnd(Tokens $tokens, $index)
      {
          ++$index;
          $count = \count($tokens);
          while ($index < $count) {
              $token = $tokens[$index];
              if ($token->isGivenKind([T_WHITESPACE, T_COMMENT, T_DOC_COMMENT])) {
                  ++$index;
  
                  continue;
              }
  
              if ($this->isOfLowerPrecedence($token)) {
                  break;
              }
  
              $block = Tokens::detectBlockType($token);
              if (null === $block) {
                  ++$index;
  
                  continue;
              }
  
              if (!$block['isStart']) {
                  break;
              }
  
              $index = $tokens->findBlockEnd($block['type'], $index) + 1;
          }
  
          $prev = $tokens->getPrevMeaningfulToken($index);
  
          return $tokens[$prev]->isGivenKind(T_CLOSE_TAG) ? $tokens->getPrevMeaningfulToken($prev) : $prev;
      }
docs: Finds the end of the right-hand side of the comparison at the given
  index.
  
  The right-hand side ends when an operator with a lower precedence is
  encountered or when the block level for `()`, `{}` or `[]` goes below
  zero.
  
  @param Tokens $tokens The token list
  @param int    $index  The index of the comparison
  
  @return int The last index of the right-hand side of the comparison