Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cd5ed3d

Browse filesBrowse files
committed
drop the validateNames option
1 parent 2ff26b7 commit cd5ed3d
Copy full SHA for cd5ed3d

File tree

Expand file treeCollapse file tree

3 files changed

+6
-6
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

3 files changed

+6
-6
lines changed
Open diff view settings
Collapse file

‎src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntax.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntax.php
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class ExpressionLanguageSyntax extends Constraint
2929

3030
public $message = 'This value should be a valid expression.';
3131
public $service;
32-
public $validateNames = true;
33-
public $names = [];
32+
public $variableNames = [];
3433

3534
/**
3635
* {@inheritdoc}
Collapse file

‎src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntaxValidator.php‎

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntaxValidator.php
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Symfony\Component\Validator\Constraint;
1717
use Symfony\Component\Validator\ConstraintValidator;
1818
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
19+
use Symfony\Component\Validator\Exception\UnexpectedValueException;
1920

2021
/**
2122
* @author Andrey Sevastianov <mrpkmail@gmail.com>
@@ -39,15 +40,15 @@ public function validate($expression, Constraint $constraint): void
3940
}
4041

4142
if (!\is_string($expression)) {
42-
throw new UnexpectedTypeException($expression, 'string');
43+
throw new UnexpectedValueException($expression, 'string');
4344
}
4445

4546
if (null === $this->expressionLanguage) {
4647
$this->expressionLanguage = new ExpressionLanguage();
4748
}
4849

4950
try {
50-
$this->expressionLanguage->lint($expression, ($constraint->validateNames ? ($constraint->names ?? []) : null));
51+
$this->expressionLanguage->lint($expression, $constraint->variableNames);
5152
} catch (SyntaxError $exception) {
5253
$this->context->buildViolation($constraint->message)
5354
->setParameter('{{ syntax_error }}', $this->formatValue($exception->getMessage()))
Collapse file

‎…traints/ExpressionLanguageSyntaxTest.php‎ ‎…xpressionLanguageSyntaxValidatorTest.php‎src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxTest.php renamed to src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxValidatorTest.php src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxTest.php renamed to src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxValidatorTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Tests/Constraints/ExpressionLanguageSyntaxValidatorTest.php
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Symfony\Component\Validator\Constraints\ExpressionLanguageSyntaxValidator;
1919
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
2020

21-
class ExpressionLanguageSyntaxTest extends ConstraintValidatorTestCase
21+
class ExpressionLanguageSyntaxValidatorTest extends ConstraintValidatorTestCase
2222
{
2323
/**
2424
* @var \PHPUnit\Framework\MockObject\MockObject|ExpressionLanguage
@@ -58,7 +58,7 @@ public function testExpressionWithoutNames(): void
5858

5959
$this->validator->validate($this->value, new ExpressionLanguageSyntax([
6060
'message' => 'myMessage',
61-
'validateNames' => false,
61+
'variableNames' => null,
6262
]));
6363

6464
$this->assertNoViolation();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.