@@ -66,11 +66,11 @@ discard block |
||
| 66 | 66 | * @param Reference|null $references references |
| 67 | 67 | */ |
| 68 | 68 | public function __construct( |
| 69 | - string|null $name = null, |
|
| 70 | - OptionsArray|null $options = null, |
|
| 71 | - DataType|Key|null $type = null, |
|
| 69 | + string | null $name = null, |
|
| 70 | + OptionsArray | null $options = null, |
|
| 71 | + DataType | Key | null $type = null, |
|
| 72 | 72 | bool $isConstraint = false, |
| 73 | - Reference|null $references = null, |
|
| 73 | + Reference | null $references = null, |
|
| 74 | 74 | ) { |
| 75 | 75 | $this->name = $name; |
| 76 | 76 | $this->options = $options; |
@@ -95,16 +95,16 @@ discard block |
||
| 95 | 95 | $tmp .= Context::escape($this->name) . ' '; |
| 96 | 96 | } |
| 97 | 97 | |
| 98 | - if (! empty($this->type)) { |
|
| 98 | + if (!empty($this->type)) { |
|
| 99 | 99 | $this->type->lowercase = true; |
| 100 | 100 | $tmp .= $this->type->build() . ' '; |
| 101 | 101 | } |
| 102 | 102 | |
| 103 | - if (! empty($this->key)) { |
|
| 103 | + if (!empty($this->key)) { |
|
| 104 | 104 | $tmp .= $this->key . ' '; |
| 105 | 105 | } |
| 106 | 106 | |
| 107 | - if (! empty($this->references)) { |
|
| 107 | + if (!empty($this->references)) { |
|
| 108 | 108 | $tmp .= 'REFERENCES ' . $this->references . ' '; |
| 109 | 109 | } |
| 110 | 110 | |
@@ -18,5 +18,5 @@ |
||
| 18 | 18 | * |
| 19 | 19 | * @return Component|Component[]|null |
| 20 | 20 | */ |
| 21 | - public static function parse(Parser $parser, TokensList $list, array $options = []): Component|array|null; |
|
| 21 | + public static function parse(Parser $parser, TokensList $list, array $options = []): Component | array | null; |
|
| 22 | 22 | } |
@@ -63,23 +63,23 @@ discard block |
||
| 63 | 63 | * |
| 64 | 64 | * @see Statement::$statementOptions |
| 65 | 65 | */ |
| 66 | - public OptionsArray|null $options = null; |
|
| 66 | + public OptionsArray | null $options = null; |
|
| 67 | 67 | |
| 68 | 68 | /** |
| 69 | 69 | * The index of the first token used in this statement. |
| 70 | 70 | */ |
| 71 | - public int|null $first = null; |
|
| 71 | + public int | null $first = null; |
|
| 72 | 72 | |
| 73 | 73 | /** |
| 74 | 74 | * The index of the last token used in this statement. |
| 75 | 75 | */ |
| 76 | - public int|null $last = null; |
|
| 76 | + public int | null $last = null; |
|
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | 79 | * @param Parser|null $parser the instance that requests parsing |
| 80 | 80 | * @param TokensList|null $list the list of tokens to be parsed |
| 81 | 81 | */ |
| 82 | - public function __construct(Parser|null $parser = null, TokensList|null $list = null) |
|
| 82 | + public function __construct(Parser | null $parser = null, TokensList | null $list = null) |
|
| 83 | 83 | { |
| 84 | 84 | if (($parser === null) || ($list === null)) { |
| 85 | 85 | return; |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | |
| 125 | 125 | // Checking if this field was already built. |
| 126 | 126 | if ($type & self::ADD_CLAUSE) { |
| 127 | - if (! empty($built[$field])) { |
|
| 127 | + if (!empty($built[$field])) { |
|
| 128 | 128 | continue; |
| 129 | 129 | } |
| 130 | 130 | |
@@ -137,7 +137,7 @@ discard block |
||
| 137 | 137 | } |
| 138 | 138 | |
| 139 | 139 | // Checking if the result of the builder should be added. |
| 140 | - if (! ($type & self::ADD_CLAUSE)) { |
|
| 140 | + if (!($type & self::ADD_CLAUSE)) { |
|
| 141 | 141 | continue; |
| 142 | 142 | } |
| 143 | 143 | |
@@ -260,8 +260,8 @@ discard block |
||
| 260 | 260 | $options = []; |
| 261 | 261 | |
| 262 | 262 | // Looking for duplicated clauses. |
| 263 | - if (isset(Parser::KEYWORD_PARSERS[$token->value]) || ! empty(Parser::STATEMENT_PARSERS[$token->value])) { |
|
| 264 | - if (! empty($parsedClauses[$token->value])) { |
|
| 263 | + if (isset(Parser::KEYWORD_PARSERS[$token->value]) || !empty(Parser::STATEMENT_PARSERS[$token->value])) { |
|
| 264 | + if (!empty($parsedClauses[$token->value])) { |
|
| 265 | 265 | $parser->error('This type of clause was previously parsed.', $token); |
| 266 | 266 | break; |
| 267 | 267 | } |
@@ -277,15 +277,15 @@ discard block |
||
| 277 | 277 | if (isset(Parser::KEYWORD_PARSERS[$tokenValue]) && $list->idx < $list->count) { |
| 278 | 278 | $class = Parser::KEYWORD_PARSERS[$tokenValue]['class']; |
| 279 | 279 | $field = Parser::KEYWORD_PARSERS[$tokenValue]['field']; |
| 280 | - if (! empty(Parser::KEYWORD_PARSERS[$tokenValue]['options'])) { |
|
| 280 | + if (!empty(Parser::KEYWORD_PARSERS[$tokenValue]['options'])) { |
|
| 281 | 281 | $options = Parser::KEYWORD_PARSERS[$tokenValue]['options']; |
| 282 | 282 | } |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | // Checking if this is the beginning of the statement. |
| 286 | - if (! empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 286 | + if (!empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 287 | 287 | if ( |
| 288 | - ! empty(static::$clauses) // Undefined for some statements. |
|
| 288 | + !empty(static::$clauses) // Undefined for some statements. |
|
| 289 | 289 | && empty(static::$clauses[$token->value]) |
| 290 | 290 | ) { |
| 291 | 291 | // Some keywords (e.g. `SET`) may be the beginning of a |
@@ -300,8 +300,8 @@ discard block |
||
| 300 | 300 | break; |
| 301 | 301 | } |
| 302 | 302 | |
| 303 | - if (! $parsedOptions) { |
|
| 304 | - if (! array_key_exists((string) $token->value, static::$statementOptions)) { |
|
| 303 | + if (!$parsedOptions) { |
|
| 304 | + if (!array_key_exists((string) $token->value, static::$statementOptions)) { |
|
| 305 | 305 | // Skipping keyword because if it is not a option. |
| 306 | 306 | ++$list->idx; |
| 307 | 307 | } |
@@ -468,7 +468,7 @@ discard block |
||
| 468 | 468 | if ($minJoin === 0 && stripos($clauseType, 'JOIN')) { |
| 469 | 469 | // First JOIN clause is detected |
| 470 | 470 | $minJoin = $maxJoin = $clauseStartIdx; |
| 471 | - } elseif ($minJoin !== 0 && ! stripos($clauseType, 'JOIN')) { |
|
| 471 | + } elseif ($minJoin !== 0 && !stripos($clauseType, 'JOIN')) { |
|
| 472 | 472 | // After a previous JOIN clause, a non-JOIN clause has been detected |
| 473 | 473 | $maxJoin = $lastIdx; |
| 474 | 474 | } elseif ($maxJoin < $clauseStartIdx && stripos($clauseType, 'JOIN')) { |
@@ -170,7 +170,7 @@ discard block |
||
| 170 | 170 | $state = 4; |
| 171 | 171 | } elseif ($token->type === TokenType::Symbol || $token->type === TokenType::None) { |
| 172 | 172 | $expr->name = $token->value; |
| 173 | - if (! $expr->isConstraint) { |
|
| 173 | + if (!$expr->isConstraint) { |
|
| 174 | 174 | $state = 2; |
| 175 | 175 | } |
| 176 | 176 | } elseif ($token->type === TokenType::Keyword) { |
@@ -211,7 +211,7 @@ discard block |
||
| 211 | 211 | |
| 212 | 212 | $state = 5; |
| 213 | 213 | } else { |
| 214 | - if (! empty($expr->type) || ! empty($expr->key)) { |
|
| 214 | + if (!empty($expr->type) || !empty($expr->key)) { |
|
| 215 | 215 | $ret[] = $expr; |
| 216 | 216 | } |
| 217 | 217 | |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | } |
| 232 | 232 | |
| 233 | 233 | // Last iteration was not saved. |
| 234 | - if (! empty($expr->type) || ! empty($expr->key)) { |
|
| 234 | + if (!empty($expr->type) || !empty($expr->key)) { |
|
| 235 | 235 | $ret[] = $expr; |
| 236 | 236 | } |
| 237 | 237 | |
@@ -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 | |
@@ -114,10 +114,10 @@ discard block |
||
| 114 | 114 | * @param string|null $alias the name of the alias |
| 115 | 115 | */ |
| 116 | 116 | public function __construct( |
| 117 | - string|null $database = null, |
|
| 118 | - string|null $table = null, |
|
| 119 | - string|null $column = null, |
|
| 120 | - string|null $alias = null, |
|
| 117 | + string | null $database = null, |
|
| 118 | + string | null $table = null, |
|
| 119 | + string | null $column = null, |
|
| 120 | + string | null $alias = null, |
|
| 121 | 121 | ) { |
| 122 | 122 | if (($column === null) && ($alias === null)) { |
| 123 | 123 | $this->expr = $database; // case 1 |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | * |
| 163 | 163 | * @throws ParserException |
| 164 | 164 | */ |
| 165 | - public static function parse(Parser $parser, TokensList $list, array $options = []): Expression|null |
|
| 165 | + public static function parse(Parser $parser, TokensList $list, array $options = []): Expression | null |
|
| 166 | 166 | { |
| 167 | 167 | $ret = new static(); |
| 168 | 168 | |
@@ -195,7 +195,7 @@ discard block |
||
| 195 | 195 | ]; |
| 196 | 196 | |
| 197 | 197 | // When a field is parsed, no parentheses are expected. |
| 198 | - if (! empty($options['parseField'])) { |
|
| 198 | + if (!empty($options['parseField'])) { |
|
| 199 | 199 | $options['breakOnParentheses'] = true; |
| 200 | 200 | $options['field'] = $options['parseField']; |
| 201 | 201 | } |
@@ -222,18 +222,18 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | if ($token->type === TokenType::Keyword) { |
| 225 | - if (($brackets > 0) && empty($ret->subquery) && ! empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 225 | + if (($brackets > 0) && empty($ret->subquery) && !empty(Parser::STATEMENT_PARSERS[$token->keyword])) { |
|
| 226 | 226 | // A `(` was previously found and this keyword is the |
| 227 | 227 | // beginning of a statement, so this is a subquery. |
| 228 | 228 | $ret->subquery = $token->keyword; |
| 229 | 229 | } elseif ( |
| 230 | 230 | ($token->flags & Token::FLAG_KEYWORD_FUNCTION) |
| 231 | 231 | && (empty($options['parseField']) |
| 232 | - && ! $alias) |
|
| 232 | + && !$alias) |
|
| 233 | 233 | ) { |
| 234 | 234 | $isExpr = true; |
| 235 | 235 | } elseif (($token->flags & Token::FLAG_KEYWORD_RESERVED) && ($brackets === 0)) { |
| 236 | - if (! in_array($token->keyword, self::ALLOWED_KEYWORDS, true)) { |
|
| 236 | + if (!in_array($token->keyword, self::ALLOWED_KEYWORDS, true)) { |
|
| 237 | 237 | // A reserved keyword that is not allowed in the |
| 238 | 238 | // expression was found so the expression must have |
| 239 | 239 | // ended and a new clause is starting. |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | } |
| 242 | 242 | |
| 243 | 243 | if ($token->keyword === 'AS') { |
| 244 | - if (! empty($options['breakOnAlias'])) { |
|
| 244 | + if (!empty($options['breakOnAlias'])) { |
|
| 245 | 245 | break; |
| 246 | 246 | } |
| 247 | 247 | |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | $isExpr = true; |
| 267 | 267 | } elseif ( |
| 268 | - $brackets === 0 && strlen((string) $ret->expr) > 0 && ! $alias |
|
| 268 | + $brackets === 0 && strlen((string) $ret->expr) > 0 && !$alias |
|
| 269 | 269 | && ($ret->table === null || $ret->table === '') |
| 270 | 270 | ) { |
| 271 | 271 | /* End of expression */ |
@@ -283,7 +283,7 @@ discard block |
||
| 283 | 283 | || (($token->type === TokenType::Operator) |
| 284 | 284 | && ($token->value !== '.')) |
| 285 | 285 | ) { |
| 286 | - if (! empty($options['parseField'])) { |
|
| 286 | + if (!empty($options['parseField'])) { |
|
| 287 | 287 | break; |
| 288 | 288 | } |
| 289 | 289 | |
@@ -293,7 +293,7 @@ discard block |
||
| 293 | 293 | } |
| 294 | 294 | |
| 295 | 295 | if ($token->type === TokenType::Operator) { |
| 296 | - if (! empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) { |
|
| 296 | + if (!empty($options['breakOnParentheses']) && (($token->value === '(') || ($token->value === ')'))) { |
|
| 297 | 297 | // No brackets were expected. |
| 298 | 298 | break; |
| 299 | 299 | } |
@@ -317,7 +317,7 @@ discard block |
||
| 317 | 317 | |
| 318 | 318 | --$brackets; |
| 319 | 319 | if ($brackets === 0) { |
| 320 | - if (! empty($options['parenthesesDelimited'])) { |
|
| 320 | + if (!empty($options['parenthesesDelimited'])) { |
|
| 321 | 321 | // The current token is the last bracket, the next |
| 322 | 322 | // one will be outside the expression. |
| 323 | 323 | $ret->expr .= $token->token; |
@@ -343,7 +343,7 @@ discard block |
||
| 343 | 343 | |
| 344 | 344 | if ($alias) { |
| 345 | 345 | // An alias is expected (the keyword `AS` was previously found). |
| 346 | - if (! empty($ret->alias)) { |
|
| 346 | + if (!empty($ret->alias)) { |
|
| 347 | 347 | $parser->error('An alias was previously found.', $token); |
| 348 | 348 | break; |
| 349 | 349 | } |
@@ -357,15 +357,15 @@ discard block |
||
| 357 | 357 | && ($prev[0] === null |
| 358 | 358 | || (($prev[0]->type !== TokenType::Operator || $prev[0]->token === ')') |
| 359 | 359 | && ($prev[0]->type !== TokenType::Keyword |
| 360 | - || ! ($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED)))) |
|
| 360 | + || !($prev[0]->flags & Token::FLAG_KEYWORD_RESERVED)))) |
|
| 361 | 361 | && (($prev[1]->type === TokenType::String) |
| 362 | 362 | || ($prev[1]->type === TokenType::Symbol |
| 363 | - && ! ($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE) |
|
| 364 | - && ! ($prev[1]->flags & Token::FLAG_SYMBOL_PARAMETER)) |
|
| 363 | + && !($prev[1]->flags & Token::FLAG_SYMBOL_VARIABLE) |
|
| 364 | + && !($prev[1]->flags & Token::FLAG_SYMBOL_PARAMETER)) |
|
| 365 | 365 | || ($prev[1]->type === TokenType::None |
| 366 | 366 | && $prev[1]->token !== 'OVER')) |
| 367 | 367 | ) { |
| 368 | - if (! empty($ret->alias)) { |
|
| 368 | + if (!empty($ret->alias)) { |
|
| 369 | 369 | $parser->error('An alias was previously found.', $token); |
| 370 | 370 | break; |
| 371 | 371 | } |
@@ -396,7 +396,7 @@ discard block |
||
| 396 | 396 | // Found a `.` which means we expect a column name and |
| 397 | 397 | // the column name we parsed is actually the table name |
| 398 | 398 | // and the table name is actually a database name. |
| 399 | - if (! empty($ret->database) || $dot) { |
|
| 399 | + if (!empty($ret->database) || $dot) { |
|
| 400 | 400 | $parser->error('Unexpected dot.', $token); |
| 401 | 401 | } |
| 402 | 402 | |
@@ -413,11 +413,11 @@ discard block |
||
| 413 | 413 | $dot = false; |
| 414 | 414 | } else { |
| 415 | 415 | // No alias is expected. |
| 416 | - if (! empty($options['breakOnAlias'])) { |
|
| 416 | + if (!empty($options['breakOnAlias'])) { |
|
| 417 | 417 | break; |
| 418 | 418 | } |
| 419 | 419 | |
| 420 | - if (! empty($ret->alias)) { |
|
| 420 | + if (!empty($ret->alias)) { |
|
| 421 | 421 | $parser->error('An alias was previously found.', $token); |
| 422 | 422 | break; |
| 423 | 423 | } |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | $ret = implode('.', Context::escapeAll($fields)); |
| 466 | 466 | } |
| 467 | 467 | |
| 468 | - if (! empty($this->alias)) { |
|
| 468 | + if (!empty($this->alias)) { |
|
| 469 | 469 | $ret .= ' AS ' . Context::escape($this->alias); |
| 470 | 470 | } |
| 471 | 471 | |