@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | public $expr; |
| 79 | 79 | |
| 80 | 80 | /** @param string $expr the condition or the operator */ |
| 81 | - public function __construct(string|null $expr = null) |
|
| 81 | + public function __construct(string | null $expr = null) |
|
| 82 | 82 | { |
| 83 | 83 | $this->expr = trim((string) $expr); |
| 84 | 84 | } |
@@ -141,7 +141,7 @@ discard block |
||
| 141 | 141 | } else { |
| 142 | 142 | // The expression ended. |
| 143 | 143 | $expr->expr = trim($expr->expr); |
| 144 | - if (! empty($expr->expr)) { |
|
| 144 | + if (!empty($expr->expr)) { |
|
| 145 | 145 | $ret[] = $expr; |
| 146 | 146 | } |
| 147 | 147 | |
@@ -159,13 +159,13 @@ discard block |
||
| 159 | 159 | if ( |
| 160 | 160 | ($token->type === TokenType::Keyword) |
| 161 | 161 | && ($token->flags & Token::FLAG_KEYWORD_RESERVED) |
| 162 | - && ! ($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
|
| 162 | + && !($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
|
| 163 | 163 | ) { |
| 164 | 164 | if ($token->value === 'BETWEEN') { |
| 165 | 165 | $betweenBefore = true; |
| 166 | 166 | } |
| 167 | 167 | |
| 168 | - if ($brackets === 0 && ! in_array($token->value, self::ALLOWED_KEYWORDS, true)) { |
|
| 168 | + if ($brackets === 0 && !in_array($token->value, self::ALLOWED_KEYWORDS, true)) { |
|
| 169 | 169 | break; |
| 170 | 170 | } |
| 171 | 171 | } |
@@ -202,7 +202,7 @@ discard block |
||
| 202 | 202 | |
| 203 | 203 | // Last iteration was not processed. |
| 204 | 204 | $expr->expr = trim($expr->expr); |
| 205 | - if (! empty($expr->expr)) { |
|
| 205 | + if (!empty($expr->expr)) { |
|
| 206 | 206 | $ret[] = $expr; |
| 207 | 207 | } |
| 208 | 208 | |
@@ -113,10 +113,10 @@ discard block |
||
| 113 | 113 | * @param string|null $alias the name of the alias |
| 114 | 114 | */ |
| 115 | 115 | public function __construct( |
| 116 | - string|null $database = null, |
|
| 117 | - string|null $table = null, |
|
| 118 | - string|null $column = null, |
|
| 119 | - string|null $alias = null, |
|
| 116 | + string | null $database = null, |
|
| 117 | + string | null $table = null, |
|
| 118 | + string | null $column = null, |
|
| 119 | + string | null $alias = null, |
|
| 120 | 120 | ) { |
| 121 | 121 | if (($column === null) && ($alias === null)) { |
| 122 | 122 | $this->expr = $database; // case 1 |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | * |
| 162 | 162 | * @throws ParserException |
| 163 | 163 | */ |
| 164 | - public static function parse(Parser $parser, TokensList $list, array $options = []): Expression|null |
|
| 164 | + public static function parse(Parser $parser, TokensList $list, array $options = []): Expression | null |
|
| 165 | 165 | { |
| 166 | 166 | $ret = new static(); |
| 167 | 167 | |
@@ -194,7 +194,7 @@ discard block |
||
| 194 | 194 | ]; |
| 195 | 195 | |
| 196 | 196 | // When a field is parsed, no parentheses are expected. |
| 197 | - if (! empty($options['parseField'])) { |
|
| 197 | + if (!empty($options['parseField'])) { |
|
| 198 | 198 | $options['breakOnParentheses'] = true; |
| 199 | 199 | $options['field'] = $options['parseField']; |
| 200 | 200 | } |
@@ -221,18 +221,18 @@ discard block |
||
| 221 | 221 | } |
| 222 | 222 | |
| 223 | 223 | if ($token->type === TokenType::Keyword) { |
| 224 | - if (($brackets > 0) && empty($ret->subquery) && ! empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 224 | + if (($brackets > 0) && empty($ret->subquery) && !empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 225 | 225 | // A `(` was previously found and this keyword is the |
| 226 | 226 | // beginning of a statement, so this is a subquery. |
| 227 | 227 | $ret->subquery = $token->keyword; |
| 228 | 228 | } elseif ( |
| 229 | 229 | ($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
| 230 | 230 | && (empty($options['parseField']) |
| 231 | - && ! $alias) |
|
| 231 | + && !$alias) |
|
| 232 | 232 | ) { |
| 233 | 233 | $isExpr = true; |
| 234 | 234 | } elseif (($token->flags & Token::FLAG_KEYWORD_RESERVED) && ($brackets === 0)) { |
| 235 | - if (! in_array($token->keyword, self::ALLOWED_KEYWORDS, true)) { |
|
| 235 | + if (!in_array($token->keyword, self::ALLOWED_KEYWORDS, true)) { |
|
| 236 | 236 | // A reserved keyword that is not allowed in the |
| 237 | 237 | // expression was found so the expression must have |
| 238 | 238 | // ended and a new clause is starting. |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | if ($token->keyword === 'AS') { |
| 243 | - if (! empty($options['breakOnAlias'])) { |
|
| 243 | + if (!empty($options['breakOnAlias'])) { |
|
| 244 | 244 | break; |
| 245 | 245 | } |
| 246 | 246 | |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | $isExpr = true; |
| 266 | - } elseif ($brackets === 0 && strlen((string) $ret->expr) > 0 && ! $alias) { |
|
| 266 | + } elseif ($brackets === 0 && strlen((string) $ret->expr) > 0 && !$alias) { |
|
| 267 | 267 | /* End of expression */ |
| 268 | 268 | break; |
| 269 | 269 | } |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | || (($token->type === TokenType::Operator) |
| 280 | 280 | && ($token->value !== '.')) |
| 281 | 281 | ) { |
| 282 | - if (! empty($options['parseField'])) { |
|
| 282 | + if (!empty($options['parseField'])) { |
|
| 283 | 283 | break; |
| 284 | 284 | } |
| 285 | 285 | |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | if ($token->type === TokenType::Operator) { |
| 292 | - if (! empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) { |
|
| 292 | + if (!empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) { |
|
| 293 | 293 | // No brackets were expected. |
| 294 | 294 | break; |
| 295 | 295 | } |
@@ -313,7 +313,7 @@ discard block |
||
| 313 | 313 | |
| 314 | 314 | --$brackets; |
| 315 | 315 | if ($brackets === 0) { |
| 316 | - if (! empty($options['parenthesesDelimited'])) { |
|
| 316 | + if (!empty($options['parenthesesDelimited'])) { |
|
| 317 | 317 | // The current token is the last bracket, the next |
| 318 | 318 | // one will be outside the expression. |
| 319 | 319 | $ret->expr .= $token->token; |
@@ -339,7 +339,7 @@ discard block |
||
| 339 | 339 | |
| 340 | 340 | if ($alias) { |
| 341 | 341 | // An alias is expected (the keyword `AS` was previously found). |
| 342 | - if (! empty($ret->alias)) { |
|
| 342 | + if (!empty($ret->alias)) { |
|
| 343 | 343 | $parser->error('An alias was previously found.', $token); |
| 344 | 344 | break; |
| 345 | 345 | } |
@@ -353,15 +353,15 @@ discard block |
||
| 353 | 353 | && ($prev[0] === null |
| 354 | 354 | || (($prev[0]->type !== TokenType::Operator || $prev[0]->token === ')') |
| 355 | 355 | && ($prev[0]->type !== TokenType::Keyword |
| 356 | - || ! ($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED)))) |
|
| 356 | + || !($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED)))) |
|
| 357 | 357 | && (($prev[1]->type === TokenType::String) |
| 358 | 358 | || ($prev[1]->type === TokenType::Symbol |
| 359 | - && ! ($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE) |
|
| 360 | - && ! ($prev[1]->flags & Token::FLAG_SYMBOL_PARAMETER)) |
|
| 359 | + && !($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE) |
|
| 360 | + && !($prev[1]->flags & Token::FLAG_SYMBOL_PARAMETER)) |
|
| 361 | 361 | || ($prev[1]->type === TokenType::None |
| 362 | 362 | && $prev[1]->token !== 'OVER')) |
| 363 | 363 | ) { |
| 364 | - if (! empty($ret->alias)) { |
|
| 364 | + if (!empty($ret->alias)) { |
|
| 365 | 365 | $parser->error('An alias was previously found.', $token); |
| 366 | 366 | break; |
| 367 | 367 | } |
@@ -392,7 +392,7 @@ discard block |
||
| 392 | 392 | // Found a `.` which means we expect a column name and |
| 393 | 393 | // the column name we parsed is actually the table name |
| 394 | 394 | // and the table name is actually a database name. |
| 395 | - if (! empty($ret->database) || $dot) { |
|
| 395 | + if (!empty($ret->database) || $dot) { |
|
| 396 | 396 | $parser->error('Unexpected dot.', $token); |
| 397 | 397 | } |
| 398 | 398 | |
@@ -409,11 +409,11 @@ discard block |
||
| 409 | 409 | $dot = false; |
| 410 | 410 | } else { |
| 411 | 411 | // No alias is expected. |
| 412 | - if (! empty($options['breakOnAlias'])) { |
|
| 412 | + if (!empty($options['breakOnAlias'])) { |
|
| 413 | 413 | break; |
| 414 | 414 | } |
| 415 | 415 | |
| 416 | - if (! empty($ret->alias)) { |
|
| 416 | + if (!empty($ret->alias)) { |
|
| 417 | 417 | $parser->error('An alias was previously found.', $token); |
| 418 | 418 | break; |
| 419 | 419 | } |
@@ -461,7 +461,7 @@ discard block |
||
| 461 | 461 | $ret = implode('.', Context::escapeAll($fields)); |
| 462 | 462 | } |
| 463 | 463 | |
| 464 | - if (! empty($this->alias)) { |
|
| 464 | + if (!empty($this->alias)) { |
|
| 465 | 465 | $ret .= ' AS ' . Context::escape($this->alias); |
| 466 | 466 | } |
| 467 | 467 | |
@@ -68,23 +68,23 @@ discard block |
||
| 68 | 68 | * |
| 69 | 69 | * @see Statement::$statementOptions |
| 70 | 70 | */ |
| 71 | - public OptionsArray|null $options = null; |
|
| 71 | + public OptionsArray | null $options = null; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * The index of the first token used in this statement. |
| 75 | 75 | */ |
| 76 | - public int|null $first = null; |
|
| 76 | + public int | null $first = null; |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * The index of the last token used in this statement. |
| 80 | 80 | */ |
| 81 | - public int|null $last = null; |
|
| 81 | + public int | null $last = null; |
|
| 82 | 82 | |
| 83 | 83 | /** |
| 84 | 84 | * @param Parser|null $parser the instance that requests parsing |
| 85 | 85 | * @param TokensList|null $list the list of tokens to be parsed |
| 86 | 86 | */ |
| 87 | - public function __construct(Parser|null $parser = null, TokensList|null $list = null) |
|
| 87 | + public function __construct(Parser | null $parser = null, TokensList | null $list = null) |
|
| 88 | 88 | { |
| 89 | 89 | if (($parser === null) || ($list === null)) { |
| 90 | 90 | return; |
@@ -151,7 +151,7 @@ discard block |
||
| 151 | 151 | |
| 152 | 152 | // Checking if this field was already built. |
| 153 | 153 | if ($type & 1) { |
| 154 | - if (! empty($built[$field])) { |
|
| 154 | + if (!empty($built[$field])) { |
|
| 155 | 155 | continue; |
| 156 | 156 | } |
| 157 | 157 | |
@@ -164,7 +164,7 @@ discard block |
||
| 164 | 164 | } |
| 165 | 165 | |
| 166 | 166 | // Checking if the result of the builder should be added. |
| 167 | - if (! ($type & 1)) { |
|
| 167 | + if (!($type & 1)) { |
|
| 168 | 168 | continue; |
| 169 | 169 | } |
| 170 | 170 | |
@@ -286,8 +286,8 @@ discard block |
||
| 286 | 286 | $options = []; |
| 287 | 287 | |
| 288 | 288 | // Looking for duplicated clauses. |
| 289 | - if (! empty(Parser::KEYWORD_PARSERS[$token->value]) || ! empty(Parser::STATEMENT_PARSERS[$token->value])) { |
|
| 290 | - if (! empty($parsedClauses[$token->value])) { |
|
| 289 | + if (!empty(Parser::KEYWORD_PARSERS[$token->value]) || !empty(Parser::STATEMENT_PARSERS[$token->value])) { |
|
| 290 | + if (!empty($parsedClauses[$token->value])) { |
|
| 291 | 291 | $parser->error('This type of clause was previously parsed.', $token); |
| 292 | 292 | break; |
| 293 | 293 | } |
@@ -300,18 +300,18 @@ discard block |
||
| 300 | 300 | // but it might be the beginning of a statement of truncate, |
| 301 | 301 | // so let the value use the keyword field for truncate type. |
| 302 | 302 | $tokenValue = in_array($token->keyword, ['TRUNCATE']) ? $token->keyword : $token->value; |
| 303 | - if (! empty(Parser::KEYWORD_PARSERS[$tokenValue]) && $list->idx < $list->count) { |
|
| 303 | + if (!empty(Parser::KEYWORD_PARSERS[$tokenValue]) && $list->idx < $list->count) { |
|
| 304 | 304 | $class = Parser::KEYWORD_PARSERS[$tokenValue]['class']; |
| 305 | 305 | $field = Parser::KEYWORD_PARSERS[$tokenValue]['field']; |
| 306 | - if (! empty(Parser::KEYWORD_PARSERS[$tokenValue]['options'])) { |
|
| 306 | + if (!empty(Parser::KEYWORD_PARSERS[$tokenValue]['options'])) { |
|
| 307 | 307 | $options = Parser::KEYWORD_PARSERS[$tokenValue]['options']; |
| 308 | 308 | } |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | // Checking if this is the beginning of the statement. |
| 312 | - if (! empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 312 | + if (!empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 313 | 313 | if ( |
| 314 | - ! empty(static::$clauses) // Undefined for some statements. |
|
| 314 | + !empty(static::$clauses) // Undefined for some statements. |
|
| 315 | 315 | && empty(static::$clauses[$token->value]) |
| 316 | 316 | ) { |
| 317 | 317 | // Some keywords (e.g. `SET`) may be the beginning of a |
@@ -326,8 +326,8 @@ discard block |
||
| 326 | 326 | break; |
| 327 | 327 | } |
| 328 | 328 | |
| 329 | - if (! $parsedOptions) { |
|
| 330 | - if (! array_key_exists((string) $token->value, static::$statementOptions)) { |
|
| 329 | + if (!$parsedOptions) { |
|
| 330 | + if (!array_key_exists((string) $token->value, static::$statementOptions)) { |
|
| 331 | 331 | // Skipping keyword because if it is not a option. |
| 332 | 332 | ++$list->idx; |
| 333 | 333 | } |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | if ($minJoin === 0 && stripos($clauseType, 'JOIN')) { |
| 496 | 496 | // First JOIN clause is detected |
| 497 | 497 | $minJoin = $maxJoin = $clauseStartIdx; |
| 498 | - } elseif ($minJoin !== 0 && ! stripos($clauseType, 'JOIN')) { |
|
| 498 | + } elseif ($minJoin !== 0 && !stripos($clauseType, 'JOIN')) { |
|
| 499 | 499 | // After a previous JOIN clause, a non-JOIN clause has been detected |
| 500 | 500 | $maxJoin = $lastIdx; |
| 501 | 501 | } elseif ($maxJoin < $clauseStartIdx && stripos($clauseType, 'JOIN')) { |