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 6d4599c

Browse filesBrowse files
committed
Make ExpressionLanguageSyntax validator usable with annotation
1 parent a73523b commit 6d4599c
Copy full SHA for 6d4599c

File tree

2 files changed

+6
-2
lines changed
Filter options

2 files changed

+6
-2
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntax.php
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ class ExpressionLanguageSyntax extends Constraint
3737
*/
3838
public function validatedBy()
3939
{
40-
return $this->service;
40+
return $this->service ?? static::class.'Validator';
4141
}
4242
}

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/Validator/Constraints/ExpressionLanguageSyntaxValidator.php
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ExpressionLanguageSyntaxValidator extends ConstraintValidator
2424
{
2525
private $expressionLanguage;
2626

27-
public function __construct(ExpressionLanguage $expressionLanguage)
27+
public function __construct(ExpressionLanguage $expressionLanguage = null)
2828
{
2929
$this->expressionLanguage = $expressionLanguage;
3030
}
@@ -42,6 +42,10 @@ public function validate($expression, Constraint $constraint): void
4242
throw new UnexpectedTypeException($expression, 'string');
4343
}
4444

45+
if (null === $this->expressionLanguage) {
46+
$this->expressionLanguage = new ExpressionLanguage();
47+
}
48+
4549
try {
4650
$this->expressionLanguage->lint($expression, ($constraint->validateNames ? ($constraint->names ?? []) : null));
4751
} catch (SyntaxError $exception) {

0 commit comments

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