In Symfony 7.4, support for the options parameter in Validator constraints was deprecated in favor of named arguments.
symfony/symfony#60801
Projects that currently use
new Recaptcha2(['message' => 'recaptcha_invalid']);
cannot safely upgrade to Symfony 8.0, even though Symfony 8 support is declared in this bundle.
At the same time, switching to
new Recaptcha2(message: 'recaptcha_invalid');
currently fails, because Recaptcha2 does not define its own constructor with a message argument.
A minimal fix would be to add an explicit constructor to the constraint
use Symfony\Component\Validator\Constraint;
final class Recaptcha2 extends Constraint
{
public string $message = 'Invalid ReCaptcha.';
public function __construct(
?string $message = null,
?array $groups = null,
mixed $payload = null,
) {
parent::__construct(null, $groups, $payload);
$this->message = $message ?? $this->message;
}
public function validatedBy(): string
{
return 'recaptcha2';
}
}
In Symfony 7.4, support for the
optionsparameter in Validator constraints was deprecated in favor of named arguments.symfony/symfony#60801
Projects that currently use
cannot safely upgrade to Symfony 8.0, even though Symfony 8 support is declared in this bundle.
At the same time, switching to
currently fails, because Recaptcha2 does not define its own constructor with a message argument.
A minimal fix would be to add an explicit constructor to the constraint