public function isBeforeStructuralElement(Tokens $tokens, $index)
    {
        $token = $tokens[$index];

        if (!$token->isGivenKind([T_COMMENT, T_DOC_COMMENT])) {
            throw new \InvalidArgumentException('Given index must point to a comment.');
        }

        $nextIndex = $index;
        do {
            $nextIndex = $tokens->getNextMeaningfulToken($nextIndex);
        } while (null !== $nextIndex && $tokens[$nextIndex]->equals('('));

        if (null === $nextIndex || $tokens[$nextIndex]->equals('}')) {
            return false;
        }

        $nextToken = $tokens[$nextIndex];

        if ($this->isStructuralElement($nextToken)) {
            return true;
        }

        if ($this->isValidControl($tokens, $token, $nextIndex)) {
            return true;
        }

        if ($this->isValidVariable($tokens, $nextIndex)) {
            return true;
        }

        if ($this->isValidLanguageConstruct($tokens, $token, $nextIndex)) {
            return true;
        }

        return false;
    }