예제 #1
0
 /**
  * Creates constraint object from tokens.
  * <p>
  * If parameter $constraintName is not passed then current position should point to the name of the constraint.
  *
  * @param Tokenizer $tokenizer Tokens collection.
  * @param string $constraintName Optional name of the constraint.
  *
  * @return Constraint
  */
 public static function create(Tokenizer $tokenizer, $constraintName = '')
 {
     if ($constraintName === false) {
         $constraintName = '';
     } elseif (!$constraintName) {
         $constraintName = $tokenizer->getCurrentToken()->text;
         $tokenizer->nextToken();
         $tokenizer->skipWhiteSpace();
     }
     $constraint = new self($constraintName);
     $token = $tokenizer->getCurrentToken();
     $level = $token->level;
     $constraintDefinition = '';
     do {
         if ($token->level == $level && $token->text == ',') {
             break;
         }
         if ($token->level < $level && $token->text == ')') {
             break;
         }
         $constraintDefinition .= $token->text;
         $token = $tokenizer->nextToken();
     } while (!$tokenizer->endOfInput());
     $constraint->setBody($constraintDefinition);
     return $constraint;
 }
예제 #2
0
 /**
  * Creates sequence object from tokens.
  * <p>
  * Current position should point to the name of the sequence.
  *
  * @param Tokenizer $tokenizer Tokens collection.
  *
  * @return Sequence
  */
 public static function create(Tokenizer $tokenizer)
 {
     $name = $tokenizer->getCurrentToken()->text;
     $sequence = new self($name);
     $tokenizer->resetState();
     $definition = '';
     while (!$tokenizer->endOfInput()) {
         $definition .= $tokenizer->getCurrentToken()->text;
         $tokenizer->nextToken();
     }
     $sequence->setBody($definition);
     return $sequence;
 }
 /**
  * Check if the current line exceeds the maxLineLength allowed.
  *
  * Launched at the start of a new line.
  */
 private function _checkLargeLine()
 {
     $checkHTMLLines = $this->_config->getTestProperty('lineLength', 'checkHTMLLines');
     // If the current token is HTML we don't check the line size
     if ($checkHTMLLines == "true" || !$this->tokenizer->checkNextValidToken(T_INLINE_HTML)) {
         $maxLength = $this->_config->getTestProperty('lineLength', 'maxLineLength');
         $lineString = "";
         // String assembled from tokens
         $currentTokenIndex = $this->tokenizer->getCurrentPosition();
         $currentToken = $this->tokenizer->getCurrentToken($currentTokenIndex);
         do {
             $currentTokenString = $currentToken->text;
             $lineString .= $currentTokenString;
             $currentTokenIndex += 1;
             $currentToken = $this->tokenizer->peekTokenAt($currentTokenIndex);
             $isNull = $currentToken == null;
             $isNewLine = !$isNull && $this->tokenizer->checkToken($currentToken, T_NEW_LINE);
         } while (!($isNull || $isNewLine));
         $lineLength = strlen($lineString);
         // Reporting the error if the line length exceeds the defined maximum.
         if ($lineLength > $maxLength) {
             // Does not report if the line is a multiline comment - i.e. has /* in it)
             if (strpos($lineString, "/*")) {
                 return;
             }
             $msg = $this->_getMessage('LONG_LINE', $lineLength, $maxLength);
             $this->_writeError('lineLength', $msg);
         }
     }
 }
예제 #4
0
 /**
  * Creates stored procedure object from tokens.
  * <p>
  * Current position should point to the type of the stored procedure (PROCEDURE, FUNCTION or TYPE).
  * <p>
  * Name may consist of two parts divided by '.'.
  *
  * @param Tokenizer $tokenizer Tokens collection.
  *
  * @return Procedure
  */
 public static function create(Tokenizer $tokenizer)
 {
     $type = $tokenizer->getCurrentToken()->text;
     $tokenizer->nextToken();
     $tokenizer->skipWhiteSpace();
     $name = $tokenizer->getCurrentToken()->text;
     $token = $tokenizer->nextToken();
     if ($token->text === '.') {
         $token = $tokenizer->nextToken();
         $name .= '.' . $token->text;
     }
     $procedure = new self($name, $type);
     $tokenizer->resetState();
     $definition = '';
     while (!$tokenizer->endOfInput()) {
         $definition .= $tokenizer->getCurrentToken()->text;
         $tokenizer->nextToken();
     }
     $procedure->setBody($definition);
     return $procedure;
 }