/** * Adds a new line break for an opening parentheses for a non-inline expression. */ public function addNewLineAfterOpeningParentheses() { if (false === $this->parentheses->getInlineParentheses()) { $this->indentation->setIncreaseBlockIndent(true); $this->newline = true; } }
/** * @param $token * @param $i * @param array $tokens * @param array $originalTokens * * @return array */ protected function formatOpeningParenthesis($token, $i, array &$tokens, array &$originalTokens) { $length = 0; for ($j = 1; $j <= 250; $j++) { if (isset($tokens[$i + $j])) { $next = $tokens[$i + $j]; if ($this->parentheses->stringIsClosingParentheses($next)) { $this->parentheses->writeNewInlineParentheses(); break; } if ($this->parentheses->invalidParenthesesTokenValue($next) || $this->parentheses->invalidParenthesesTokenType($next)) { break; } $length += strlen($next[Tokenizer::TOKEN_VALUE]); } } $this->newLine->writeNewLineForLongInlineValues($length); if (WhiteSpace::isPrecedingCurrentTokenOfTokenTypeWhiteSpace($originalTokens, $token)) { $this->formattedSql = rtrim($this->formattedSql, ' '); } $this->newLine->addNewLineAfterOpeningParentheses(); return $tokens; }
/** * @param string $token * @param Parentheses $parentheses * @param Formatter $formatter */ public static function tokenHasLimitClause($token, Parentheses $parentheses, Formatter $formatter) { if ('LIMIT' === $token[Tokenizer::TOKEN_VALUE] && false === $parentheses->getInlineParentheses()) { $formatter->setClauseLimit(true); } }