Skip to content

Commit

Permalink
Fix keyword parsing
Browse files Browse the repository at this point in the history
Signed-off-by: Kamil Tekiela <[email protected]>
  • Loading branch information
kamil-tekiela committed Oct 15, 2024
1 parent bc9ce73 commit af85abd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -960,11 +960,6 @@ parameters:
count: 1
path: src/Utils/Query.php

-
message: "#^Parameter \\#1 \\$str of function strtoupper expects string, mixed given\\.$#"
count: 1
path: src/Utils/Query.php

-
message: "#^Cannot access offset 'value' on mixed\\.$#"
count: 3
Expand Down
6 changes: 5 additions & 1 deletion psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1336,6 +1336,9 @@
<DocblockTypeContradiction occurrences="1">
<code>! ($statement instanceof SelectStatement)</code>
</DocblockTypeContradiction>
<MixedArrayOffset occurrences="1">
<code>$tables[$thisDb][$expr-&gt;table]</code>
</MixedArrayOffset>
<PossiblyNullArrayOffset occurrences="1">
<code>$tables[$thisDb]</code>
</PossiblyNullArrayOffset>
Expand All @@ -1348,9 +1351,10 @@
<code>$expr</code>
<code>$expr-&gt;function</code>
</MixedArgument>
<MixedArrayOffset occurrences="2">
<MixedArrayOffset occurrences="3">
<code>$clauses[$token-&gt;keyword]</code>
<code>$clauses[$token-&gt;keyword]</code>
<code>$tableAliases[$expr-&gt;table]</code>
</MixedArrayOffset>
<MixedArrayTypeCoercion occurrences="2">
<code>$clauses[$token-&gt;keyword]</code>
Expand Down
5 changes: 4 additions & 1 deletion src/Components/Condition.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ public static function parse(Parser $parser, TokensList $list, array $options =
}

// Conditions are delimited by logical operators.
if (in_array($token->value, static::$DELIMITERS, true)) {
if (
($token->type === Token::TYPE_KEYWORD || $token->type === Token::TYPE_OPERATOR)
&& in_array($token->value, static::$DELIMITERS, true)
) {
if ($betweenBefore && ($token->value === 'AND')) {
// The syntax of keyword `BETWEEN` is hard-coded.
$betweenBefore = false;
Expand Down

0 comments on commit af85abd

Please sign in to comment.