Skip to content

Commit 70336e3

Browse files
authored
[Bug] Fix lexer token and workflows (#260)
* fix: parser errors caused by lexer version update * fix: sonar
1 parent 81fbc6b commit 70336e3

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

.github/workflows/php-cs-fixer.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: "PHP-CS-Fixer"
22

33
on:
4-
pull_request:
4+
pull_request_target:
55
branches:
66
- "[0-9]+.[0-9]+"
77
- "[0-9]+.x"
@@ -24,7 +24,8 @@ jobs:
2424
steps:
2525
- uses: actions/checkout@v2
2626
with:
27-
ref: ${{ github.head_ref }}
27+
ref: ${{ github.event.pull_request.head.ref }}
28+
repository: ${{ github.event.pull_request.head.repo.full_name }}
2829

2930
- name: PHP-CS-Fixer
3031
uses: docker://oskarstark/php-cs-fixer-ga:latest

.github/workflows/sonar.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ on:
33
push:
44
branches:
55
- 1.x
6-
pull_request:
6+
pull_request_target:
77
types: [opened, synchronize, reopened]
88
jobs:
99
sonarcloud:
@@ -13,6 +13,8 @@ jobs:
1313
- uses: actions/checkout@v3
1414
with:
1515
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
16+
ref: ${{ github.event.pull_request.head.ref }}
17+
repository: ${{ github.event.pull_request.head.repo.full_name }}
1618
- name: SonarCloud Scan
1719
uses: SonarSource/sonarcloud-github-action@master
1820
env:

src/QueryLanguage/Pql/Parser.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private function expectRightParenthesis(): void
112112
if (!$token || !$token->isA(QueryTokenType::T_RPAREN)) {
113113
$this->throwParsingException(
114114
'token type `' . QueryTokenType::T_RPAREN->value . '`',
115-
'`' . ($token['type']->value ?? 'null') . '`'
115+
'`' . ($token->type ?? 'null') . '`'
116116
);
117117
}
118118
$this->advance();
@@ -175,7 +175,7 @@ private function parseComparison(array &$subQueries): array|ParseResultSubQuery
175175
$this->validateCurrentTokenNotEmpty();
176176

177177
if (!$this->currentToken() || !$this->currentToken()->isA(...self::FIELD_NAME_TOKENS)) {
178-
$tokenValue = $this->currentToken()['value'] ?? 'null';
178+
$tokenValue = $this->currentToken()->value ?? 'null';
179179
$message = null;
180180
if (in_arrayi($tokenValue, ['and', 'or', 'like', 'not like', 'null', 'empty'])) {
181181
$message = sprintf('Expected %s, found %s.', 'a field name', '`' . $tokenValue . '`')
@@ -186,15 +186,15 @@ private function parseComparison(array &$subQueries): array|ParseResultSubQuery
186186

187187
/** @var Token $fieldToken */
188188
$fieldToken = $this->currentToken();
189-
$fieldType = $fieldToken['type'];
190-
$field = $fieldToken['value'];
189+
$fieldType = $fieldToken->type;
190+
$field = $fieldToken->value;
191191
$this->advance(); // Move to operator
192192
$this->validateCurrentTokenNotEmpty();
193193

194194
$operatorToken = $this->currentToken();
195195

196196
if ($operatorToken === null || !$operatorToken->isA(...self::OPERATOR_TOKENS)) {
197-
$this->throwParsingException('a comparison operator', '`' . ($operatorToken['value'] ?? 'null') . '`');
197+
$this->throwParsingException('a comparison operator', '`' . $operatorToken->value . '`');
198198
}
199199

200200
$this->advance(); // Move to value
@@ -205,7 +205,7 @@ private function parseComparison(array &$subQueries): array|ParseResultSubQuery
205205
if (!$valueToken || !$valueToken->isA(...self::VALUE_TOKENS)) {
206206
$this->throwParsingException(
207207
'a string, numeric value or a empty/null keyword',
208-
'`' . ($valueToken['value'] ?? 'null') . '`'
208+
'`' . $valueToken->value . '`'
209209
);
210210
}
211211

@@ -214,7 +214,7 @@ private function parseComparison(array &$subQueries): array|ParseResultSubQuery
214214
) {
215215
$this->throwParsingException(
216216
'a valid value',
217-
'`' . ($valueToken['value'] ?? 'null') . '`',
217+
'`' . $valueToken->value . '`',
218218
'Operator `' . $operatorToken->value . '` does not support null/empty values'
219219
);
220220
}
@@ -345,7 +345,7 @@ public function parse(): ParseResult
345345
$query = $this->parseCondition($subQueries);
346346

347347
if ($token = $this->currentToken()) {
348-
$this->throwParsingException('end of input', '`' . ($token['value'] ?? 'null') . '`');
348+
$this->throwParsingException('end of input', '`' . $token->value . '`');
349349
}
350350

351351
return new ParseResult($query, $subQueries);

0 commit comments

Comments
 (0)