Skip to content

Commit 336a86a

Browse files
committed
Dev: Define the Security and Validation exception.
1 parent f1c9caf commit 336a86a

2 files changed

Lines changed: 51 additions & 9 deletions

File tree

system/Security/Exceptions/SecurityException.php

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,35 @@
1616

1717
class SecurityException extends FrameworkException implements HTTPExceptionInterface
1818
{
19-
public static function forDisallowedAction(): self
19+
/**
20+
* Throws when some specific is not allowed.
21+
*
22+
* @return static
23+
*/
24+
public static function forDisallowedAction()
2025
{
2126
return new static(lang('Security.disallowedAction'), 403);
2227
}
2328

24-
public static function forInvalidUTF8Chars(string $source, string $string): self
29+
/**
30+
* Throws when the source string contains invalid UTF-8 characters.
31+
*
32+
* @return static
33+
*/
34+
public static function forInvalidUTF8Chars(string $source, string $string)
2535
{
2636
return new static(
2737
'Invalid UTF-8 characters in ' . $source . ': ' . $string,
2838
400
2939
);
3040
}
3141

32-
public static function forInvalidControlChars(string $source, string $string): self
42+
/**
43+
* Throws when the source string contains invalid control characters.
44+
*
45+
* @return static
46+
*/
47+
public static function forInvalidControlChars(string $source, string $string)
3348
{
3449
return new static(
3550
'Invalid Control characters in ' . $source . ': ' . $string,
@@ -41,8 +56,10 @@ public static function forInvalidControlChars(string $source, string $string): s
4156
* @deprecated Use `CookieException::forInvalidSameSite()` instead.
4257
*
4358
* @codeCoverageIgnore
59+
*
60+
* @return static
4461
*/
45-
public static function forInvalidSameSite(string $samesite): self
62+
public static function forInvalidSameSite(string $samesite)
4663
{
4764
return new static(lang('Security.invalidSameSite', [$samesite]));
4865
}

system/Validation/Exceptions/ValidationException.php

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,52 @@
1515

1616
class ValidationException extends FrameworkException
1717
{
18-
public static function forRuleNotFound(?string $rule = null): ValidationException
18+
/**
19+
* Throws when the validation rule is not found.
20+
*
21+
* @return static
22+
*/
23+
public static function forRuleNotFound(?string $rule = null)
1924
{
2025
return new static(lang('Validation.ruleNotFound', [$rule]));
2126
}
2227

23-
public static function forGroupNotFound(?string $group = null): ValidationException
28+
/**
29+
* Throws when the group value of config is not isset.
30+
*
31+
* @return static
32+
*/
33+
public static function forGroupNotFound(?string $group = null)
2434
{
2535
return new static(lang('Validation.groupNotFound', [$group]));
2636
}
2737

28-
public static function forGroupNotArray(?string $group = null): ValidationException
38+
/**
39+
* Throws when the group value of config is not array type.
40+
*
41+
* @return static
42+
*/
43+
public static function forGroupNotArray(?string $group = null)
2944
{
3045
return new static(lang('Validation.groupNotArray', [$group]));
3146
}
3247

33-
public static function forInvalidTemplate(?string $template = null): ValidationException
48+
/**
49+
* Throws when the template of config is invalid.
50+
*
51+
* @return static
52+
*/
53+
public static function forInvalidTemplate(?string $template = null)
3454
{
3555
return new static(lang('Validation.invalidTemplate', [$template]));
3656
}
3757

38-
public static function forNoRuleSets(): ValidationException
58+
/**
59+
* Throws when there is no any rule set.
60+
*
61+
* @return static
62+
*/
63+
public static function forNoRuleSets()
3964
{
4065
return new static(lang('Validation.noRuleSets'));
4166
}

0 commit comments

Comments
 (0)