Skip to content

Commit 5aa3b2e

Browse files
committed
Changed private static array-properties to const
1 parent ac0fbf6 commit 5aa3b2e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

Constraints/EmailValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class EmailValidator extends ConstraintValidator
3535
*/
3636
public const PATTERN_LOOSE = '/^.+\@\S+\.\S+$/';
3737

38-
private static $emailPatterns = [
38+
private const EMAIL_PATTERNS = [
3939
Email::VALIDATION_MODE_LOOSE => self::PATTERN_LOOSE,
4040
Email::VALIDATION_MODE_HTML5 => self::PATTERN_HTML5,
4141
];
@@ -129,7 +129,7 @@ public function validate($value, Constraint $constraint)
129129

130130
return;
131131
}
132-
} elseif (!preg_match(self::$emailPatterns[$constraint->mode], $value)) {
132+
} elseif (!preg_match(self::EMAIL_PATTERNS[$constraint->mode], $value)) {
133133
$this->context->buildViolation($constraint->message)
134134
->setParameter('{{ value }}', $this->formatValue($value))
135135
->setCode(Email::INVALID_FORMAT_ERROR)

Constraints/FileValidator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FileValidator extends ConstraintValidator
3030
public const KIB_BYTES = 1024;
3131
public const MIB_BYTES = 1048576;
3232

33-
private static $suffices = [
33+
private const SUFFICES = [
3434
1 => 'bytes',
3535
self::KB_BYTES => 'kB',
3636
self::MB_BYTES => 'MB',
@@ -247,6 +247,6 @@ private function factorizeSizes(int $size, $limit, bool $binaryFormat): array
247247
$sizeAsString = (string) round($size / $coef, 2);
248248
}
249249

250-
return [$sizeAsString, $limitAsString, self::$suffices[$coef]];
250+
return [$sizeAsString, $limitAsString, self::SUFFICES[$coef]];
251251
}
252252
}

Constraints/IbanValidator.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class IbanValidator extends ConstraintValidator
3636
*
3737
* @see https://www.swift.com/sites/default/files/resources/iban_registry.pdf
3838
*/
39-
private static $formats = [
39+
private const FORMATS = [
4040
'AD' => 'AD\d{2}\d{4}\d{4}[\dA-Z]{12}', // Andorra
4141
'AE' => 'AE\d{2}\d{3}\d{16}', // United Arab Emirates
4242
'AL' => 'AL\d{2}\d{8}[\dA-Z]{16}', // Albania
@@ -182,7 +182,7 @@ public function validate($value, Constraint $constraint)
182182
}
183183

184184
// ...have a format available
185-
if (!\array_key_exists($countryCode, self::$formats)) {
185+
if (!\array_key_exists($countryCode, self::FORMATS)) {
186186
$this->context->buildViolation($constraint->message)
187187
->setParameter('{{ value }}', $this->formatValue($value))
188188
->setCode(Iban::NOT_SUPPORTED_COUNTRY_CODE_ERROR)
@@ -192,7 +192,7 @@ public function validate($value, Constraint $constraint)
192192
}
193193

194194
// ...and have a valid format
195-
if (!preg_match('/^'.self::$formats[$countryCode].'$/', $canonicalized)
195+
if (!preg_match('/^'.self::FORMATS[$countryCode].'$/', $canonicalized)
196196
) {
197197
$this->context->buildViolation($constraint->message)
198198
->setParameter('{{ value }}', $this->formatValue($value))

0 commit comments

Comments
 (0)