Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,6 @@ class ExpressionLanguageSyntax extends Constraint
*/
public function validatedBy()
{
return $this->service;
return $this->service ?? static::class.'Validator';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ExpressionLanguageSyntaxValidator extends ConstraintValidator
{
private $expressionLanguage;

public function __construct(ExpressionLanguage $expressionLanguage)
public function __construct(ExpressionLanguage $expressionLanguage = null)
{
$this->expressionLanguage = $expressionLanguage;
}
Expand All @@ -42,6 +42,10 @@ public function validate($expression, Constraint $constraint): void
throw new UnexpectedTypeException($expression, 'string');
}

if (null === $this->expressionLanguage) {
$this->expressionLanguage = new ExpressionLanguage();
}

try {
$this->expressionLanguage->lint($expression, ($constraint->validateNames ? ($constraint->names ?? []) : null));
} catch (SyntaxError $exception) {
Expand Down