예제 #1
0
 private void checkModifiers(List<SyntaxToken> modifiers) {
   if (modifiers.size() > 1) {
     int i = 0;
     for (SyntaxToken modifier : modifiers) {
       String normalizedModifier = modifier.text().toLowerCase(Locale.ENGLISH);
       while (i < EXPECTED_ORDER.length && !EXPECTED_ORDER[i].equals(normalizedModifier)) {
         i++;
       }
     }
     if (i == EXPECTED_ORDER.length) {
       context().newIssue(this, MESSAGE).tree(modifiers.get(0));
     }
   }
 }
  /**
   * Check that there is exactly one space between a control structure keyword and a opening
   * parenthesis or curly brace.
   */
  private void checkSpaceBetweenKeywordAndNextNode(SyntaxToken keyword, SyntaxToken nextToken) {
    if (TokenUtils.isType(nextToken, PHPPunctuator.LCURLYBRACE, PHPPunctuator.LPARENTHESIS)
        && TokenUtils.isOnSameLine(keyword, nextToken)) {
      int nbSpace = TokenUtils.getNbSpaceBetween(keyword, nextToken);

      if (nbSpace != 1) {
        String endMessage =
            String.format(
                CONTROL_STRUCTURES_KEYWORD_MESSAGE,
                keyword.text(),
                TokenUtils.isType(nextToken, PHPPunctuator.LPARENTHESIS)
                    ? "parenthesis."
                    : "curly brace.");
        check.reportIssue(TokenUtils.buildIssueMsg(nbSpace, endMessage), keyword);
      }
    }
  }