@@ -215,8 +215,8 @@ public static function parse(Parser $parser, TokensList $list, array $options =
215215 }
216216
217217 if ($ token ->type === Token::TYPE_KEYWORD ) {
218- if (($ brackets > 0 ) && ( empty ($ ret ->subquery ) )
219- && ( !empty (Parser::$ STATEMENT_PARSERS [$ token ->keyword ]) )
218+ if (($ brackets > 0 ) && empty ($ ret ->subquery )
219+ && !empty (Parser::$ STATEMENT_PARSERS [$ token ->keyword ])
220220 ) {
221221 // A `(` was previously found and this keyword is the
222222 // beginning of a statement, so this is a subquery.
@@ -282,39 +282,41 @@ public static function parse(Parser $parser, TokensList $list, array $options =
282282 }
283283
284284 if ($ token ->type === Token::TYPE_OPERATOR ) {
285- if (( !empty ($ options ['breakOnParentheses ' ]) )
285+ if (!empty ($ options ['breakOnParentheses ' ])
286286 && (($ token ->value === '( ' ) || ($ token ->value === ') ' ))
287287 ) {
288288 // No brackets were expected.
289289 break ;
290290 }
291291 if ($ token ->value === '( ' ) {
292292 ++$ brackets ;
293- if (( empty ($ ret ->function ) ) && ($ prev [1 ] !== null )
293+ if (empty ($ ret ->function ) && ($ prev [1 ] !== null )
294294 && (($ prev [1 ]->type === Token::TYPE_NONE )
295295 || ($ prev [1 ]->type === Token::TYPE_SYMBOL )
296296 || (($ prev [1 ]->type === Token::TYPE_KEYWORD )
297297 && ($ prev [1 ]->flags & Token::FLAG_KEYWORD_FUNCTION )))
298298 ) {
299299 $ ret ->function = $ prev [1 ]->value ;
300300 }
301- } elseif ($ token ->value === ') ' && $ brackets == 0 ) {
302- // Not our bracket
303- break ;
304301 } elseif ($ token ->value === ') ' ) {
305- --$ brackets ;
306302 if ($ brackets === 0 ) {
307- if (!empty ($ options ['parenthesesDelimited ' ])) {
308- // The current token is the last bracket, the next
309- // one will be outside the expression.
310- $ ret ->expr .= $ token ->token ;
311- ++$ list ->idx ;
303+ // Not our bracket
304+ break ;
305+ } else {
306+ --$ brackets ;
307+ if ($ brackets === 0 ) {
308+ if (!empty ($ options ['parenthesesDelimited ' ])) {
309+ // The current token is the last bracket, the next
310+ // one will be outside the expression.
311+ $ ret ->expr .= $ token ->token ;
312+ ++$ list ->idx ;
313+ break ;
314+ }
315+ } elseif ($ brackets < 0 ) {
316+ // $parser->error('Unexpected closing bracket.', $token);
317+ // $brackets = 0;
312318 break ;
313319 }
314- } elseif ($ brackets < 0 ) {
315- // $parser->error('Unexpected closing bracket.', $token);
316- // $brackets = 0;
317- break ;
318320 }
319321 } elseif ($ token ->value === ', ' ) {
320322 // Expressions are comma-delimited.
@@ -362,7 +364,7 @@ public static function parse(Parser $parser, TokensList $list, array $options =
362364 // Found a `.` which means we expect a column name and
363365 // the column name we parsed is actually the table name
364366 // and the table name is actually a database name.
365- if (( !empty ($ ret ->database )) || ( $ dot) ) {
367+ if (!empty ($ ret ->database ) || $ dot ) {
366368 $ parser ->error ('Unexpected dot. ' , $ token );
367369 }
368370 $ ret ->database = $ ret ->table ;
@@ -426,13 +428,13 @@ public static function build($component, array $options = array())
426428 $ ret = $ component ->expr ;
427429 } else {
428430 $ fields = array ();
429- if (( isset ($ component ->database ) ) && ($ component ->database !== '' )) {
431+ if (isset ($ component ->database ) && ($ component ->database !== '' )) {
430432 $ fields [] = $ component ->database ;
431433 }
432- if (( isset ($ component ->table ) ) && ($ component ->table !== '' )) {
434+ if (isset ($ component ->table ) && ($ component ->table !== '' )) {
433435 $ fields [] = $ component ->table ;
434436 }
435- if (( isset ($ component ->column ) ) && ($ component ->column !== '' )) {
437+ if (isset ($ component ->column ) && ($ component ->column !== '' )) {
436438 $ fields [] = $ component ->column ;
437439 }
438440 $ ret = implode ('. ' , Context::escape ($ fields ));
0 commit comments