function Expression::__construct
Same name in this branch
- 11.1.x vendor/nikic/php-parser/lib/PhpParser/Node/Stmt/Expression.php \PhpParser\Node\Stmt\Expression::__construct()
- 11.1.x vendor/phpdocumentor/type-resolver/src/Types/Expression.php \phpDocumentor\Reflection\Types\Expression::__construct()
Parameters
string|ExpressionObject|array<string,mixed>|null $expression The expression to evaluate:
array<string,mixed>|null $values The values of the custom variables used in the expression (defaults to an empty array):
string[]|null $groups:
array<string,mixed> $options:
bool|null $negate Whether to fail if the expression evaluates to true (defaults to false):
Overrides Constraint::__construct
File
-
vendor/
symfony/ validator/ Constraints/ Expression.php, line 48
Class
- Expression
- Validates a value using an expression from the Expression Language component.
Namespace
Symfony\Component\Validator\ConstraintsCode
public function __construct(string|ExpressionObject|array|null $expression, ?string $message = null, ?array $values = null, ?array $groups = null, mixed $payload = null, array $options = [], ?bool $negate = null) {
if (!class_exists(ExpressionLanguage::class)) {
throw new LogicException(\sprintf('The "symfony/expression-language" component is required to use the "%s" constraint. Try running "composer require symfony/expression-language".', __CLASS__));
}
if (\is_array($expression)) {
$options = array_merge($expression, $options);
}
else {
$options['value'] = $expression;
}
parent::__construct($options, $groups, $payload);
$this->message = $message ?? $this->message;
$this->values = $values ?? $this->values;
$this->negate = $negate ?? $this->negate;
}