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 +238,13 @@ public function parsePrimaryExpression(): Node\Node
224
238
225
239
default:
226
240
if ('(' === $this->stream->current->value) {
227
-
if (false === isset($this->functions[$token->value])) {
241
+
if (!($this->flags & self::IGNORE_UNKNOWN_FUNCTIONS) && false === isset($this->functions[$token->value])) {
228
242
thrownewSyntaxError(sprintf('The function "%s" does not exist.', $token->value), $token->cursor, $this->stream->getExpression(), $token->value, array_keys($this->functions));
if (!($this->flags & self::IGNORE_UNKNOWN_VARIABLES)) {
234
248
if (!\in_array($token->value, $this->names, true)) {
235
249
thrownewSyntaxError(sprintf('Variable "%s" is not valid.', $token->value), $token->cursor, $this->stream->getExpression(), $token->value, $this->names);
'disallow expression with unknown names by default' => [
337
348
'expression' => 'foo.bar',
338
349
'names' => [],
350
+
'checks' => 0,
339
351
'exception' => 'Variable "foo" is not valid around position 1 for expression `foo.bar',
340
352
],
353
+
'disallow expression with unknown functions by default' => [
354
+
'expression' => 'foo()',
355
+
'names' => [],
356
+
'checks' => 0,
357
+
'exception' => 'The function "foo" does not exist around position 1 for expression `foo()',
358
+
],
341
359
'operator collisions' => [
342
360
'expression' => 'foo.not in [bar]',
343
361
'names' => ['foo', 'bar'],
344
362
],
345
363
'incorrect expression ending' => [
346
364
'expression' => 'foo["a"] foo["b"]',
347
365
'names' => ['foo'],
366
+
'checks' => 0,
348
367
'exception' => 'Unexpected token "name" of value "foo" '.
349
368
'around position 10 for expression `foo["a"] foo["b"]`.',
350
369
],
351
370
'incorrect operator' => [
352
371
'expression' => 'foo["some_key"] // 2',
353
372
'names' => ['foo'],
373
+
'checks' => 0,
354
374
'exception' => 'Unexpected token "operator" of value "/" '.
355
375
'around position 18 for expression `foo["some_key"] // 2`.',
356
376
],
357
377
'incorrect array' => [
358
378
'expression' => '[value1, value2 value3]',
359
379
'names' => ['value1', 'value2', 'value3'],
380
+
'checks' => 0,
360
381
'exception' => 'An array element must be followed by a comma. '.
361
382
'Unexpected token "name" of value "value3" ("punctuation" expected with value ",") '.
362
383
'around position 17 for expression `[value1, value2 value3]`.',
363
384
],
364
385
'incorrect array element' => [
365
386
'expression' => 'foo["some_key")',
366
387
'names' => ['foo'],
388
+
'checks' => 0,
367
389
'exception' => 'Unclosed "[" around position 3 for expression `foo["some_key")`.',
368
390
],
369
391
'incorrect hash key' => [
370
392
'expression' => '{+: value1}',
371
393
'names' => ['value1'],
394
+
'checks' => 0,
372
395
'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
396
],
374
397
'missed array key' => [
375
398
'expression' => 'foo[]',
376
399
'names' => ['foo'],
400
+
'checks' => 0,
377
401
'exception' => 'Unexpected token "punctuation" of value "]" around position 5 for expression `foo[]`.',
378
402
],
379
403
'missed closing bracket in sub expression' => [
380
404
'expression' => 'foo[(bar ? bar : "default"]',
381
405
'names' => ['foo', 'bar'],
406
+
'checks' => 0,
382
407
'exception' => 'Unclosed "(" around position 4 for expression `foo[(bar ? bar : "default"]`.',
383
408
],
384
409
'incorrect hash following' => [
385
410
'expression' => '{key: foo key2: bar}',
386
411
'names' => ['foo', 'bar'],
412
+
'checks' => 0,
387
413
'exception' => 'A hash value must be followed by a comma. '.
388
414
'Unexpected token "name" of value "key2" ("punctuation" expected with value ",") '.
389
415
'around position 11 for expression `{key: foo key2: bar}`.',
390
416
],
391
417
'incorrect hash assign' => [
392
418
'expression' => '{key => foo}',
393
419
'names' => ['foo'],
420
+
'checks' => 0,
394
421
'exception' => 'Unexpected character "=" around position 5 for expression `{key => foo}`.',
395
422
],
396
423
'incorrect array as hash using' => [
397
424
'expression' => '[foo: foo]',
398
425
'names' => ['foo'],
426
+
'checks' => 0,
399
427
'exception' => 'An array element must be followed by a comma. '.
400
428
'Unexpected token "punctuation" of value ":" ("punctuation" expected with value ",") '.
0 commit comments