Skip to content

Commit

Permalink
Apply php-cs-fixer formatting changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mostertb committed Oct 13, 2018
1 parent 61343f6 commit bf4ad3d
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions src/Components/CaseExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ class CaseExpression extends Component
public $else_result;

/**
* The alias of this CASE statement
* The alias of this CASE statement.
*
* @var string
*/
Expand All @@ -78,8 +78,8 @@ public function __construct()
}

/**
* @param Parser $parser the parser that serves as context
* @param TokensList $list the list of tokens that are being parsed
* @param Parser $parser the parser that serves as context
* @param TokensList $list the list of tokens that are being parsed
* @param array $options parameters for parsing
*
* @return CaseExpression
Expand Down Expand Up @@ -209,7 +209,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
$list->tokens[$list->idx - 1]
);
} else {

// Parse for alias of CASE expression
$asFound = false;
for (; $list->idx < $list->count; ++$list->idx) {
Expand All @@ -219,6 +218,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
if ($token->type === Token::TYPE_DELIMITER) {
break;
}

// Skipping whitespaces and comments.
if (($token->type === Token::TYPE_WHITESPACE)
|| ($token->type === Token::TYPE_COMMENT)
Expand All @@ -227,9 +227,8 @@ public static function parse(Parser $parser, TokensList $list, array $options =
}

// Handle optional AS keyword before alias
if($token->type === Token::TYPE_KEYWORD
&& $token->keyword === 'AS'){

if ($token->type === Token::TYPE_KEYWORD
&& $token->keyword === 'AS') {
if ($asFound || !empty($ret->alias)) {
$parser->error('Potential duplicate alias of CASE expression.', $token);
break;
Expand All @@ -240,8 +239,8 @@ public static function parse(Parser $parser, TokensList $list, array $options =

if ($asFound
&& $token->type === Token::TYPE_KEYWORD
&& ($token->flags & Token::FLAG_KEYWORD_RESERVED || $token->flags & Token::FLAG_KEYWORD_FUNCTION)){
$parser->error('An alias expected after AS but got '.$token->value, $token);
&& ($token->flags & Token::FLAG_KEYWORD_RESERVED || $token->flags & Token::FLAG_KEYWORD_FUNCTION)) {
$parser->error('An alias expected after AS but got ' . $token->value, $token);
$asFound = false;
break;
}
Expand All @@ -250,8 +249,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
|| $token->type === Token::TYPE_STRING
|| ($token->type === Token::TYPE_SYMBOL && !$token->flags & Token::FLAG_SYMBOL_VARIABLE)
|| $token->type === Token::TYPE_NONE
){

) {
// An alias is expected (the keyword `AS` was previously found).
if (!empty($ret->alias)) {
$parser->error('An alias was previously found.', $token);
Expand All @@ -269,7 +267,6 @@ public static function parse(Parser $parser, TokensList $list, array $options =
$parser->error('An alias was expected after AS.', $list->tokens[$list->idx - 1]);
}


$ret->expr = self::build($ret);
}

Expand Down

0 comments on commit bf4ad3d

Please sign in to comment.