Skip to content

Commit 0b712c7

Browse files
Add type to final/internal public/protected properties
1 parent e2fe377 commit 0b712c7

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

Constraints/Email.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,16 @@ class Email extends Constraint
3131

3232
public const INVALID_FORMAT_ERROR = 'bd79c0ab-ddba-46cc-a703-a7a4b08de310';
3333

34-
protected static $errorNames = [
35-
self::INVALID_FORMAT_ERROR => 'STRICT_CHECK_FAILED_ERROR',
36-
];
37-
38-
/**
39-
* @var string[]
40-
*
41-
* @internal
42-
*/
43-
public static $validationModes = [
34+
public const VALIDATION_MODES = [
4435
self::VALIDATION_MODE_HTML5,
4536
self::VALIDATION_MODE_STRICT,
4637
self::VALIDATION_MODE_LOOSE,
4738
];
4839

40+
protected static $errorNames = [
41+
self::INVALID_FORMAT_ERROR => 'STRICT_CHECK_FAILED_ERROR',
42+
];
43+
4944
public $message = 'This value is not a valid email address.';
5045
public $mode;
5146
public $normalizer;
@@ -58,7 +53,7 @@ public function __construct(
5853
array $groups = null,
5954
mixed $payload = null
6055
) {
61-
if (\is_array($options) && \array_key_exists('mode', $options) && !\in_array($options['mode'], self::$validationModes, true)) {
56+
if (\is_array($options) && \array_key_exists('mode', $options) && !\in_array($options['mode'], self::VALIDATION_MODES, true)) {
6257
throw new InvalidArgumentException('The "mode" parameter value is not valid.');
6358
}
6459

Constraints/EmailValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class EmailValidator extends ConstraintValidator
3636

3737
public function __construct(string $defaultMode = Email::VALIDATION_MODE_LOOSE)
3838
{
39-
if (!\in_array($defaultMode, Email::$validationModes, true)) {
39+
if (!\in_array($defaultMode, Email::VALIDATION_MODES, true)) {
4040
throw new \InvalidArgumentException('The "defaultMode" parameter value is not valid.');
4141
}
4242

@@ -73,7 +73,7 @@ public function validate(mixed $value, Constraint $constraint)
7373
$constraint->mode = $this->defaultMode;
7474
}
7575

76-
if (!\in_array($constraint->mode, Email::$validationModes, true)) {
76+
if (!\in_array($constraint->mode, Email::VALIDATION_MODES, true)) {
7777
throw new \InvalidArgumentException(sprintf('The "%s::$mode" parameter value is not valid.', get_debug_type($constraint)));
7878
}
7979

0 commit comments

Comments
 (0)