Skip to content

Commit af85abd

Browse files
committed
Fix keyword parsing
Signed-off-by: Kamil Tekiela <[email protected]>
1 parent bc9ce73 commit af85abd

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

phpstan-baseline.neon

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -960,11 +960,6 @@ parameters:
960960
count: 1
961961
path: src/Utils/Query.php
962962

963-
-
964-
message: "#^Parameter \\#1 \\$str of function strtoupper expects string, mixed given\\.$#"
965-
count: 1
966-
path: src/Utils/Query.php
967-
968963
-
969964
message: "#^Cannot access offset 'value' on mixed\\.$#"
970965
count: 3

psalm-baseline.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,9 @@
13361336
<DocblockTypeContradiction occurrences="1">
13371337
<code>! ($statement instanceof SelectStatement)</code>
13381338
</DocblockTypeContradiction>
1339+
<MixedArrayOffset occurrences="1">
1340+
<code>$tables[$thisDb][$expr-&gt;table]</code>
1341+
</MixedArrayOffset>
13391342
<PossiblyNullArrayOffset occurrences="1">
13401343
<code>$tables[$thisDb]</code>
13411344
</PossiblyNullArrayOffset>
@@ -1348,9 +1351,10 @@
13481351
<code>$expr</code>
13491352
<code>$expr-&gt;function</code>
13501353
</MixedArgument>
1351-
<MixedArrayOffset occurrences="2">
1354+
<MixedArrayOffset occurrences="3">
13521355
<code>$clauses[$token-&gt;keyword]</code>
13531356
<code>$clauses[$token-&gt;keyword]</code>
1357+
<code>$tableAliases[$expr-&gt;table]</code>
13541358
</MixedArrayOffset>
13551359
<MixedArrayTypeCoercion occurrences="2">
13561360
<code>$clauses[$token-&gt;keyword]</code>

src/Components/Condition.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,10 @@ public static function parse(Parser $parser, TokensList $list, array $options =
146146
}
147147

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

0 commit comments

Comments
 (0)