From aa9d55a2922f0607b5a29c9e5f60c2c4b4cfe86c Mon Sep 17 00:00:00 2001 From: Antoine Griffon Date: Wed, 10 Dec 2025 18:42:46 +0100 Subject: [PATCH 1/2] SF8 deprecations solving --- src/EmailChecker/Constraints/NotThrowawayEmail.php | 11 ++++++++--- .../Constraints/NotThrowawayEmailValidator.php | 6 +----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/EmailChecker/Constraints/NotThrowawayEmail.php b/src/EmailChecker/Constraints/NotThrowawayEmail.php index 4a554e6..7b967bc 100644 --- a/src/EmailChecker/Constraints/NotThrowawayEmail.php +++ b/src/EmailChecker/Constraints/NotThrowawayEmail.php @@ -27,11 +27,16 @@ class NotThrowawayEmail extends Constraint public $message = 'The domain associated with this email is not valid.'; public function __construct( - $options = null, + array|string|null $message = null, ?array $groups = null, - $payload = null, - ?string $message = null, + mixed $payload = null, ) { + $options = []; + if (\is_array($message)) { + $options = $message; + $message = $options['message'] ?? null; + } + parent::__construct($options, $groups, $payload); $this->message = $message ?? $this->message; diff --git a/src/EmailChecker/Constraints/NotThrowawayEmailValidator.php b/src/EmailChecker/Constraints/NotThrowawayEmailValidator.php index 2596b74..e03d27f 100644 --- a/src/EmailChecker/Constraints/NotThrowawayEmailValidator.php +++ b/src/EmailChecker/Constraints/NotThrowawayEmailValidator.php @@ -12,7 +12,6 @@ namespace EmailChecker\Constraints; use EmailChecker\EmailChecker; -use ReturnTypeWillChange; use Symfony\Component\Validator\Constraint; use Symfony\Component\Validator\ConstraintValidator; use Symfony\Component\Validator\Exception\UnexpectedTypeException; @@ -34,11 +33,8 @@ public function __construct(?EmailChecker $emailChecker = null) /** * @param mixed $value - * - * @return void */ - #[ReturnTypeWillChange] - public function validate($value, Constraint $constraint) + public function validate($value, Constraint $constraint): void { if (!$constraint instanceof NotThrowawayEmail) { throw new UnexpectedTypeException($constraint, NotThrowawayEmail::class); From 6c2d6a76be5cfae4a0b5301b52af8ec2f4985032 Mon Sep 17 00:00:00 2001 From: Antoine Griffon Date: Wed, 10 Dec 2025 18:45:00 +0100 Subject: [PATCH 2/2] phpstan --- src/EmailChecker/Constraints/NotThrowawayEmail.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/EmailChecker/Constraints/NotThrowawayEmail.php b/src/EmailChecker/Constraints/NotThrowawayEmail.php index 7b967bc..78c962e 100644 --- a/src/EmailChecker/Constraints/NotThrowawayEmail.php +++ b/src/EmailChecker/Constraints/NotThrowawayEmail.php @@ -26,6 +26,9 @@ class NotThrowawayEmail extends Constraint */ public $message = 'The domain associated with this email is not valid.'; + /** + * @param array|string|null $message + */ public function __construct( array|string|null $message = null, ?array $groups = null,