You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
trigger_deprecation('symfony/expression-language', '7.1', 'Passing "null" as the second argument of "%s()" is deprecated, pass "self::IGNORE_UNKNOWN_VARIABLES" instead as a third argument.', __METHOD__);
trigger_deprecation('symfony/expression-language', '7.1', 'Passing "null" as the second argument of "%s()" is deprecated, pass "self::IGNORE_UNKNOWN_VARIABLES" instead as a third argument.', __METHOD__);
@@ -224,13 +236,13 @@ public function parsePrimaryExpression(): Node\Node
224
236
225
237
default:
226
238
if ('(' === $this->stream->current->value) {
227
-
if (false === isset($this->functions[$token->value])) {
239
+
if (!($this->checks & self::IGNORE_UNKNOWN_FUNCTIONS) && false === isset($this->functions[$token->value])) {
228
240
thrownewSyntaxError(sprintf('The function "%s" does not exist.', $token->value), $token->cursor, $this->stream->getExpression(), $token->value, array_keys($this->functions));
if (!($this->checks & self::IGNORE_UNKNOWN_VARIABLES)) {
234
246
if (!\in_array($token->value, $this->names, true)) {
235
247
thrownewSyntaxError(sprintf('Variable "%s" is not valid.', $token->value), $token->cursor, $this->stream->getExpression(), $token->value, $this->names);
// Parser does't return anything when the correct expression is passed
310
310
$this->expectNotToPerformAssertions();
@@ -323,7 +323,8 @@ public static function getLintData(): array
323
323
],
324
324
'allow expression without names' => [
325
325
'expression' => 'foo.bar',
326
-
'names' => null,
326
+
'names' => [],
327
+
'checks' => Parser::IGNORE_UNKNOWN_VARIABLES,
327
328
],
328
329
'array with trailing comma' => [
329
330
'expression' => '[value1, value2, value3,]',
@@ -336,6 +337,7 @@ public static function getLintData(): array
336
337
'disallow expression without names' => [
337
338
'expression' => 'foo.bar',
338
339
'names' => [],
340
+
'checks' => 0,
339
341
'exception' => 'Variable "foo" is not valid around position 1 for expression `foo.bar',
340
342
],
341
343
'operator collisions' => [
@@ -345,57 +347,67 @@ public static function getLintData(): array
345
347
'incorrect expression ending' => [
346
348
'expression' => 'foo["a"] foo["b"]',
347
349
'names' => ['foo'],
350
+
'checks' => 0,
348
351
'exception' => 'Unexpected token "name" of value "foo" '.
349
352
'around position 10 for expression `foo["a"] foo["b"]`.',
350
353
],
351
354
'incorrect operator' => [
352
355
'expression' => 'foo["some_key"] // 2',
353
356
'names' => ['foo'],
357
+
'checks' => 0,
354
358
'exception' => 'Unexpected token "operator" of value "/" '.
355
359
'around position 18 for expression `foo["some_key"] // 2`.',
356
360
],
357
361
'incorrect array' => [
358
362
'expression' => '[value1, value2 value3]',
359
363
'names' => ['value1', 'value2', 'value3'],
364
+
'checks' => 0,
360
365
'exception' => 'An array element must be followed by a comma. '.
361
366
'Unexpected token "name" of value "value3" ("punctuation" expected with value ",") '.
362
367
'around position 17 for expression `[value1, value2 value3]`.',
363
368
],
364
369
'incorrect array element' => [
365
370
'expression' => 'foo["some_key")',
366
371
'names' => ['foo'],
372
+
'checks' => 0,
367
373
'exception' => 'Unclosed "[" around position 3 for expression `foo["some_key")`.',
368
374
],
369
375
'incorrect hash key' => [
370
376
'expression' => '{+: value1}',
371
377
'names' => ['value1'],
378
+
'checks' => 0,
372
379
'exception' => 'A hash key must be a quoted string, a number, a name, or an expression enclosed in parentheses (unexpected token "operator" of value "+" around position 2 for expression `{+: value1}`.',
373
380
],
374
381
'missed array key' => [
375
382
'expression' => 'foo[]',
376
383
'names' => ['foo'],
384
+
'checks' => 0,
377
385
'exception' => 'Unexpected token "punctuation" of value "]" around position 5 for expression `foo[]`.',
378
386
],
379
387
'missed closing bracket in sub expression' => [
380
388
'expression' => 'foo[(bar ? bar : "default"]',
381
389
'names' => ['foo', 'bar'],
390
+
'checks' => 0,
382
391
'exception' => 'Unclosed "(" around position 4 for expression `foo[(bar ? bar : "default"]`.',
383
392
],
384
393
'incorrect hash following' => [
385
394
'expression' => '{key: foo key2: bar}',
386
395
'names' => ['foo', 'bar'],
396
+
'checks' => 0,
387
397
'exception' => 'A hash value must be followed by a comma. '.
388
398
'Unexpected token "name" of value "key2" ("punctuation" expected with value ",") '.
389
399
'around position 11 for expression `{key: foo key2: bar}`.',
390
400
],
391
401
'incorrect hash assign' => [
392
402
'expression' => '{key => foo}',
393
403
'names' => ['foo'],
404
+
'checks' => 0,
394
405
'exception' => 'Unexpected character "=" around position 5 for expression `{key => foo}`.',
395
406
],
396
407
'incorrect array as hash using' => [
397
408
'expression' => '[foo: foo]',
398
409
'names' => ['foo'],
410
+
'checks' => 0,
399
411
'exception' => 'An array element must be followed by a comma. '.
400
412
'Unexpected token "punctuation" of value ":" ("punctuation" expected with value ",") '.
0 commit comments