@@ -121,7 +121,7 @@ |
||
| 121 | 121 | } |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - if (! empty($expr->type)) { |
|
| 124 | + if (!empty($expr->type)) { |
|
| 125 | 125 | $ret[] = $expr; |
| 126 | 126 | } |
| 127 | 127 | |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | if ($token->type === TokenType::Operator && $token->value === '(') { |
| 88 | 88 | --$list->idx; // ArrayObj needs to start with `(` |
| 89 | 89 | $state = 1; |
| 90 | - continue;// do not add this token to the name |
|
| 90 | + continue; // do not add this token to the name |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | $ret->name .= $token->value; |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | ) { |
| 89 | 89 | $expr->type = $token->keyword; |
| 90 | 90 | } elseif (($token->type === TokenType::Operator) && ($token->value === ',')) { |
| 91 | - if (! empty($expr->expr)) { |
|
| 91 | + if (!empty($expr->expr)) { |
|
| 92 | 92 | $ret[] = $expr; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Last iteration was not processed. |
| 104 | - if (! empty($expr->expr)) { |
|
| 104 | + if (!empty($expr->expr)) { |
|
| 105 | 105 | $ret[] = $expr; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | * |
| 81 | 81 | * @throws ParserException |
| 82 | 82 | */ |
| 83 | - public static function parse(Parser $parser, TokensList $list, array $options = []): Expression|null |
|
| 83 | + public static function parse(Parser $parser, TokensList $list, array $options = []): Expression | null |
|
| 84 | 84 | { |
| 85 | 85 | $ret = new Expression(); |
| 86 | 86 | |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | ]; |
| 114 | 114 | |
| 115 | 115 | // When a field is parsed, no parentheses are expected. |
| 116 | - if (! empty($options['parseField'])) { |
|
| 116 | + if (!empty($options['parseField'])) { |
|
| 117 | 117 | $options['breakOnParentheses'] = true; |
| 118 | 118 | $options['field'] = $options['parseField']; |
| 119 | 119 | } |
@@ -140,18 +140,18 @@ discard block |
||
| 140 | 140 | } |
| 141 | 141 | |
| 142 | 142 | if ($token->type === TokenType::Keyword) { |
| 143 | - if (($brackets > 0) && empty($ret->subquery) && ! empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 143 | + if (($brackets > 0) && empty($ret->subquery) && !empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 144 | 144 | // A `(` was previously found and this keyword is the |
| 145 | 145 | // beginning of a statement, so this is a subquery. |
| 146 | 146 | $ret->subquery = $token->keyword; |
| 147 | 147 | } elseif ( |
| 148 | 148 | ($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
| 149 | 149 | && (empty($options['parseField']) |
| 150 | - && ! $alias) |
|
| 150 | + && !$alias) |
|
| 151 | 151 | ) { |
| 152 | 152 | $isExpr = true; |
| 153 | 153 | } elseif (($token->flags & Token::FLAG_KEYWORD_RESERVED) && ($brackets === 0)) { |
| 154 | - if (! in_array($token->keyword, self::ALLOWED_KEYWORDS, true)) { |
|
| 154 | + if (!in_array($token->keyword, self::ALLOWED_KEYWORDS, true)) { |
|
| 155 | 155 | // A reserved keyword that is not allowed in the |
| 156 | 156 | // expression was found so the expression must have |
| 157 | 157 | // ended and a new clause is starting. |
@@ -159,7 +159,7 @@ discard block |
||
| 159 | 159 | } |
| 160 | 160 | |
| 161 | 161 | if ($token->keyword === 'AS') { |
| 162 | - if (! empty($options['breakOnAlias'])) { |
|
| 162 | + if (!empty($options['breakOnAlias'])) { |
|
| 163 | 163 | break; |
| 164 | 164 | } |
| 165 | 165 | |
@@ -183,7 +183,7 @@ discard block |
||
| 183 | 183 | |
| 184 | 184 | $isExpr = true; |
| 185 | 185 | } elseif ( |
| 186 | - $brackets === 0 && strlen((string) $ret->expr) > 0 && ! $alias |
|
| 186 | + $brackets === 0 && strlen((string) $ret->expr) > 0 && !$alias |
|
| 187 | 187 | && ($ret->table === null || $ret->table === '') |
| 188 | 188 | ) { |
| 189 | 189 | /* End of expression */ |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | || (($token->type === TokenType::Operator) |
| 202 | 202 | && ($token->value !== '.')) |
| 203 | 203 | ) { |
| 204 | - if (! empty($options['parseField'])) { |
|
| 204 | + if (!empty($options['parseField'])) { |
|
| 205 | 205 | break; |
| 206 | 206 | } |
| 207 | 207 | |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | } |
| 212 | 212 | |
| 213 | 213 | if ($token->type === TokenType::Operator) { |
| 214 | - if (! empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) { |
|
| 214 | + if (!empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) { |
|
| 215 | 215 | // No brackets were expected. |
| 216 | 216 | break; |
| 217 | 217 | } |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | |
| 236 | 236 | --$brackets; |
| 237 | 237 | if ($brackets === 0) { |
| 238 | - if (! empty($options['parenthesesDelimited'])) { |
|
| 238 | + if (!empty($options['parenthesesDelimited'])) { |
|
| 239 | 239 | // The current token is the last bracket, the next |
| 240 | 240 | // one will be outside the expression. |
| 241 | 241 | $ret->expr .= $token->token; |
@@ -261,7 +261,7 @@ discard block |
||
| 261 | 261 | |
| 262 | 262 | if ($alias) { |
| 263 | 263 | // An alias is expected (the keyword `AS` was previously found). |
| 264 | - if (! empty($ret->alias)) { |
|
| 264 | + if (!empty($ret->alias)) { |
|
| 265 | 265 | $parser->error('An alias was previously found.', $token); |
| 266 | 266 | break; |
| 267 | 267 | } |
@@ -275,15 +275,15 @@ discard block |
||
| 275 | 275 | && ($prev[0] === null |
| 276 | 276 | || (($prev[0]->type !== TokenType::Operator || $prev[0]->token === ')') |
| 277 | 277 | && ($prev[0]->type !== TokenType::Keyword |
| 278 | - || ! ($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED)))) |
|
| 278 | + || !($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED)))) |
|
| 279 | 279 | && (($prev[1]->type === TokenType::String) |
| 280 | 280 | || ($prev[1]->type === TokenType::Symbol |
| 281 | - && ! ($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE) |
|
| 282 | - && ! ($prev[1]->flags & Token::FLAG_SYMBOL_PARAMETER)) |
|
| 281 | + && !($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE) |
|
| 282 | + && !($prev[1]->flags & Token::FLAG_SYMBOL_PARAMETER)) |
|
| 283 | 283 | || ($prev[1]->type === TokenType::None |
| 284 | 284 | && $prev[1]->token !== 'OVER')) |
| 285 | 285 | ) { |
| 286 | - if (! empty($ret->alias)) { |
|
| 286 | + if (!empty($ret->alias)) { |
|
| 287 | 287 | $parser->error('An alias was previously found.', $token); |
| 288 | 288 | break; |
| 289 | 289 | } |
@@ -314,7 +314,7 @@ discard block |
||
| 314 | 314 | // Found a `.` which means we expect a column name and |
| 315 | 315 | // the column name we parsed is actually the table name |
| 316 | 316 | // and the table name is actually a database name. |
| 317 | - if (! empty($ret->database) || $dot) { |
|
| 317 | + if (!empty($ret->database) || $dot) { |
|
| 318 | 318 | $parser->error('Unexpected dot.', $token); |
| 319 | 319 | } |
| 320 | 320 | |
@@ -331,11 +331,11 @@ discard block |
||
| 331 | 331 | $dot = false; |
| 332 | 332 | } else { |
| 333 | 333 | // No alias is expected. |
| 334 | - if (! empty($options['breakOnAlias'])) { |
|
| 334 | + if (!empty($options['breakOnAlias'])) { |
|
| 335 | 335 | break; |
| 336 | 336 | } |
| 337 | 337 | |
| 338 | - if (! empty($ret->alias)) { |
|
| 338 | + if (!empty($ret->alias)) { |
|
| 339 | 339 | $parser->error('An alias was previously found.', $token); |
| 340 | 340 | break; |
| 341 | 341 | } |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | } else { |
| 116 | 116 | // The expression ended. |
| 117 | 117 | $expr->expr = trim($expr->expr); |
| 118 | - if (! empty($expr->expr)) { |
|
| 118 | + if (!empty($expr->expr)) { |
|
| 119 | 119 | $ret[] = $expr; |
| 120 | 120 | } |
| 121 | 121 | |
@@ -133,13 +133,13 @@ discard block |
||
| 133 | 133 | if ( |
| 134 | 134 | ($token->type === TokenType::Keyword) |
| 135 | 135 | && ($token->flags & Token::FLAG_KEYWORD_RESERVED) |
| 136 | - && ! ($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
|
| 136 | + && !($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
|
| 137 | 137 | ) { |
| 138 | 138 | if ($token->value === 'BETWEEN') { |
| 139 | 139 | $betweenBefore = true; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - if ($brackets === 0 && ! in_array($token->value, self::ALLOWED_KEYWORDS, true)) { |
|
| 142 | + if ($brackets === 0 && !in_array($token->value, self::ALLOWED_KEYWORDS, true)) { |
|
| 143 | 143 | break; |
| 144 | 144 | } |
| 145 | 145 | } |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | // Last iteration was not processed. |
| 178 | 178 | $expr->expr = trim($expr->expr); |
| 179 | - if (! empty($expr->expr)) { |
|
| 179 | + if (!empty($expr->expr)) { |
|
| 180 | 180 | $ret[] = $expr; |
| 181 | 181 | } |
| 182 | 182 | |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | ) { |
| 89 | 89 | $expr->type = $token->keyword; |
| 90 | 90 | } elseif (($token->type === TokenType::Operator) && ($token->value === ',')) { |
| 91 | - if (! empty($expr->expr)) { |
|
| 91 | + if (!empty($expr->expr)) { |
|
| 92 | 92 | $ret[] = $expr; |
| 93 | 93 | } |
| 94 | 94 | |
@@ -101,7 +101,7 @@ discard block |
||
| 101 | 101 | } |
| 102 | 102 | |
| 103 | 103 | // Last iteration was not processed. |
| 104 | - if (! empty($expr->expr)) { |
|
| 104 | + if (!empty($expr->expr)) { |
|
| 105 | 105 | $ret[] = $expr; |
| 106 | 106 | } |
| 107 | 107 | |
@@ -87,7 +87,7 @@ |
||
| 87 | 87 | |
| 88 | 88 | // Skip if not a number or a bind parameter (?) |
| 89 | 89 | if ( |
| 90 | - ! ($token->type === TokenType::Number |
|
| 90 | + !($token->type === TokenType::Number |
|
| 91 | 91 | || ($token->type === TokenType::Symbol && ($token->flags & Token::FLAG_SYMBOL_PARAMETER))) |
| 92 | 92 | ) { |
| 93 | 93 | break; |
@@ -112,9 +112,9 @@ discard block |
||
| 112 | 112 | } elseif ($state === 1) { |
| 113 | 113 | if (($token->type === TokenType::Operator) && ($token->value === '(')) { |
| 114 | 114 | $positionBeforeSearch = $list->idx; |
| 115 | - $list->idx++;// Ignore the current token "(" or the search condition will always be true |
|
| 115 | + $list->idx++; // Ignore the current token "(" or the search condition will always be true |
|
| 116 | 116 | $nextToken = $list->getNext(); |
| 117 | - $list->idx = $positionBeforeSearch;// Restore the position |
|
| 117 | + $list->idx = $positionBeforeSearch; // Restore the position |
|
| 118 | 118 | |
| 119 | 119 | if ($nextToken !== null && $nextToken->value === '(') { |
| 120 | 120 | // Switch to expression mode |
@@ -163,7 +163,7 @@ discard block |
||
| 163 | 163 | if ($token->type === TokenType::Operator) { |
| 164 | 164 | // This got back to here and we reached the end of the expression |
| 165 | 165 | if ($token->value === ')') { |
| 166 | - $state = 4;// go back to state 4 to fetch options |
|
| 166 | + $state = 4; // go back to state 4 to fetch options |
|
| 167 | 167 | continue; |
| 168 | 168 | } |
| 169 | 169 | |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $options = []; |
| 35 | 35 | foreach ($this->options as $option) { |
| 36 | - if (! is_array($option)) { |
|
| 36 | + if (!is_array($option)) { |
|
| 37 | 37 | $options[] = $option; |
| 38 | 38 | } else { |
| 39 | 39 | $options[] = $option['name'] |
| 40 | - . (! empty($option['equals']) ? '=' : ' ') |
|
| 41 | - . (! empty($option['expr']) ? $option['expr'] : $option['value']); |
|
| 40 | + . (!empty($option['equals']) ? '=' : ' ') |
|
| 41 | + . (!empty($option['expr']) ? $option['expr'] : $option['value']); |
|
| 42 | 42 | } |
| 43 | 43 | } |
| 44 | 44 | |
@@ -56,10 +56,10 @@ discard block |
||
| 56 | 56 | { |
| 57 | 57 | foreach ($this->options as $option) { |
| 58 | 58 | if (is_array($option)) { |
| 59 | - if (! strcasecmp($key, $option['name'])) { |
|
| 59 | + if (!strcasecmp($key, $option['name'])) { |
|
| 60 | 60 | return $getExpr ? $option['expr'] : $option['value']; |
| 61 | 61 | } |
| 62 | - } elseif (! strcasecmp($key, $option)) { |
|
| 62 | + } elseif (!strcasecmp($key, $option)) { |
|
| 63 | 63 | return true; |
| 64 | 64 | } |
| 65 | 65 | } |
@@ -78,12 +78,12 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | foreach ($this->options as $idx => $option) { |
| 80 | 80 | if (is_array($option)) { |
| 81 | - if (! strcasecmp($key, $option['name'])) { |
|
| 81 | + if (!strcasecmp($key, $option['name'])) { |
|
| 82 | 82 | unset($this->options[$idx]); |
| 83 | 83 | |
| 84 | 84 | return true; |
| 85 | 85 | } |
| 86 | - } elseif (! strcasecmp($key, $option)) { |
|
| 86 | + } elseif (!strcasecmp($key, $option)) { |
|
| 87 | 87 | unset($this->options[$idx]); |
| 88 | 88 | |
| 89 | 89 | return true; |