Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0d11716

Browse files
committed
Decouple constants from intl
1 parent 8588022 commit 0d11716

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

src/Symfony/Component/Validator/Constraints/NoSuspiciousCharacters.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ class NoSuspiciousCharacters extends Constraint
2525
{
2626
/**
2727
* Check that a string satisfies the requirements for the specified restriction level
28-
* (by default {@see \Spoofchecker::HIGHLY_RESTRICTIVE}).
28+
* (by default {@see self::RESTRICTION_LEVEL_HIGH}).
2929
*/
3030
public const CHECK_RESTRICTION_LEVEL = 16;
3131

3232
/**
3333
* Check a string for the presence of invisible characters such as zero-width spaces,
3434
* or character sequences that are likely not to display such as multiple occurrences of the same non-spacing mark.
3535
*/
36-
public const CHECK_INVISIBLE = \Spoofchecker::INVISIBLE;
36+
public const CHECK_INVISIBLE = 32;
3737

3838
/** Check a string contains only characters allowed by the configured profile. */
39-
public const CHECK_CHAR_LIMIT = \Spoofchecker::CHAR_LIMIT;
39+
public const CHECK_CHAR_LIMIT = 64;
4040

4141
/**
4242
* Check that a string does not mix numbers from different numbering systems;
@@ -50,14 +50,22 @@ class NoSuspiciousCharacters extends Constraint
5050
*/
5151
public const CHECK_HIDDEN_OVERLAY = 256;
5252

53+
public const RESTRICTION_LEVEL_ASCII = 268435456;
54+
public const RESTRICTION_LEVEL_SINGLE_SCRIPT = 536870912;
55+
public const RESTRICTION_LEVEL_HIGH = 805306368;
56+
public const RESTRICTION_LEVEL_MODERATE = 1073741824;
57+
public const RESTRICTION_LEVEL_MINIMAL = 1342177280;
58+
public const RESTRICTION_LEVEL_NONE = 1610612736;
59+
5360
public $message = 'This value is suspicious.';
5461
public int $checks = self::CHECK_RESTRICTION_LEVEL | self::CHECK_INVISIBLE | self::CHECK_CHAR_LIMIT | self::CHECK_MIXED_NUMBERS | self::CHECK_HIDDEN_OVERLAY;
55-
public int $restrictionLevel = \Spoofchecker::HIGHLY_RESTRICTIVE;
62+
public int $restrictionLevel = self::RESTRICTION_LEVEL_HIGH;
5663
public array $profileLocales = [];
5764
public bool $addCurrentLocaleToProfile = true;
5865

5966
/**
6067
* @param int-mask-of<self::CHECK_*>|null $checks
68+
* @param self::RESTRICTION_LEVEL_*|null $restrictionLevel
6169
*/
6270
public function __construct(
6371
array $options = null,

src/Symfony/Component/Validator/Tests/Constraints/NoSuspiciousCharactersValidatorTest.php

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,17 @@ public static function provideSuspiciousStrings(): iterable
8484
'checks' => NoSuspiciousCharacters::CHECK_HIDDEN_OVERLAY,
8585
]];
8686
}
87+
88+
public function testConstants(): void
89+
{
90+
$this->assertSame(\Spoofchecker::INVISIBLE, NoSuspiciousCharacters::CHECK_INVISIBLE);
91+
$this->assertSame(\Spoofchecker::CHAR_LIMIT, NoSuspiciousCharacters::CHECK_CHAR_LIMIT);
92+
93+
$this->assertSame(\Spoofchecker::ASCII, NoSuspiciousCharacters::RESTRICTION_LEVEL_ASCII);
94+
$this->assertSame(\Spoofchecker::SINGLE_SCRIPT_RESTRICTIVE, NoSuspiciousCharacters::RESTRICTION_LEVEL_SINGLE_SCRIPT);
95+
$this->assertSame(\Spoofchecker::HIGHLY_RESTRICTIVE, NoSuspiciousCharacters::RESTRICTION_LEVEL_HIGH);
96+
$this->assertSame(\Spoofchecker::MODERATELY_RESTRICTIVE, NoSuspiciousCharacters::RESTRICTION_LEVEL_MODERATE);
97+
$this->assertSame(\Spoofchecker::MINIMALLY_RESTRICTIVE, NoSuspiciousCharacters::RESTRICTION_LEVEL_MINIMAL);
98+
$this->assertSame(\Spoofchecker::UNRESTRICTIVE, NoSuspiciousCharacters::RESTRICTION_LEVEL_NONE);
99+
}
87100
}

0 commit comments

Comments
 (0)