Skip to content

Commit aaf6b34

Browse files
authored
Merge pull request #7772 from ping-yee/230804-phpstan-Security-Validation
Dev: Remove the `Security` and `Validation` ignore errors in phpstan-baseline.php
2 parents e0a1094 + 61f8bd5 commit aaf6b34

File tree

5 files changed

+54
-60
lines changed

5 files changed

+54
-60
lines changed

phpstan-baseline.php

-60
Original file line numberDiff line numberDiff line change
@@ -1416,26 +1416,6 @@
14161416
'count' => 1,
14171417
'path' => __DIR__ . '/system/Router/RouterInterface.php',
14181418
];
1419-
$ignoreErrors[] = [
1420-
'message' => '#^Method CodeIgniter\\\\Security\\\\Exceptions\\\\SecurityException\\:\\:forDisallowedAction\\(\\) has no return type specified\\.$#',
1421-
'count' => 1,
1422-
'path' => __DIR__ . '/system/Security/Exceptions/SecurityException.php',
1423-
];
1424-
$ignoreErrors[] = [
1425-
'message' => '#^Method CodeIgniter\\\\Security\\\\Exceptions\\\\SecurityException\\:\\:forInvalidControlChars\\(\\) has no return type specified\\.$#',
1426-
'count' => 1,
1427-
'path' => __DIR__ . '/system/Security/Exceptions/SecurityException.php',
1428-
];
1429-
$ignoreErrors[] = [
1430-
'message' => '#^Method CodeIgniter\\\\Security\\\\Exceptions\\\\SecurityException\\:\\:forInvalidSameSite\\(\\) has no return type specified\\.$#',
1431-
'count' => 1,
1432-
'path' => __DIR__ . '/system/Security/Exceptions/SecurityException.php',
1433-
];
1434-
$ignoreErrors[] = [
1435-
'message' => '#^Method CodeIgniter\\\\Security\\\\Exceptions\\\\SecurityException\\:\\:forInvalidUTF8Chars\\(\\) has no return type specified\\.$#',
1436-
'count' => 1,
1437-
'path' => __DIR__ . '/system/Security/Exceptions/SecurityException.php',
1438-
];
14391419
$ignoreErrors[] = [
14401420
'message' => '#^Method CodeIgniter\\\\Session\\\\Exceptions\\\\SessionException\\:\\:forEmptySavepath\\(\\) has no return type specified\\.$#',
14411421
'count' => 1,
@@ -2201,51 +2181,11 @@
22012181
'count' => 1,
22022182
'path' => __DIR__ . '/system/Throttle/Throttler.php',
22032183
];
2204-
$ignoreErrors[] = [
2205-
'message' => '#^Method CodeIgniter\\\\Validation\\\\Exceptions\\\\ValidationException\\:\\:forGroupNotArray\\(\\) has no return type specified\\.$#',
2206-
'count' => 1,
2207-
'path' => __DIR__ . '/system/Validation/Exceptions/ValidationException.php',
2208-
];
2209-
$ignoreErrors[] = [
2210-
'message' => '#^Method CodeIgniter\\\\Validation\\\\Exceptions\\\\ValidationException\\:\\:forGroupNotFound\\(\\) has no return type specified\\.$#',
2211-
'count' => 1,
2212-
'path' => __DIR__ . '/system/Validation/Exceptions/ValidationException.php',
2213-
];
2214-
$ignoreErrors[] = [
2215-
'message' => '#^Method CodeIgniter\\\\Validation\\\\Exceptions\\\\ValidationException\\:\\:forInvalidTemplate\\(\\) has no return type specified\\.$#',
2216-
'count' => 1,
2217-
'path' => __DIR__ . '/system/Validation/Exceptions/ValidationException.php',
2218-
];
2219-
$ignoreErrors[] = [
2220-
'message' => '#^Method CodeIgniter\\\\Validation\\\\Exceptions\\\\ValidationException\\:\\:forNoRuleSets\\(\\) has no return type specified\\.$#',
2221-
'count' => 1,
2222-
'path' => __DIR__ . '/system/Validation/Exceptions/ValidationException.php',
2223-
];
2224-
$ignoreErrors[] = [
2225-
'message' => '#^Method CodeIgniter\\\\Validation\\\\Exceptions\\\\ValidationException\\:\\:forRuleNotFound\\(\\) has no return type specified\\.$#',
2226-
'count' => 1,
2227-
'path' => __DIR__ . '/system/Validation/Exceptions/ValidationException.php',
2228-
];
22292184
$ignoreErrors[] = [
22302185
'message' => '#^Method CodeIgniter\\\\Validation\\\\Validation\\:\\:isClosure\\(\\) has parameter \\$rule with no signature specified for Closure\\.$#',
22312186
'count' => 1,
22322187
'path' => __DIR__ . '/system/Validation/Validation.php',
22332188
];
2234-
$ignoreErrors[] = [
2235-
'message' => '#^Method CodeIgniter\\\\Validation\\\\Validation\\:\\:loadRuleSets\\(\\) has no return type specified\\.$#',
2236-
'count' => 1,
2237-
'path' => __DIR__ . '/system/Validation/Validation.php',
2238-
];
2239-
$ignoreErrors[] = [
2240-
'message' => '#^Method CodeIgniter\\\\Validation\\\\Validation\\:\\:setRuleGroup\\(\\) has no return type specified\\.$#',
2241-
'count' => 1,
2242-
'path' => __DIR__ . '/system/Validation/Validation.php',
2243-
];
2244-
$ignoreErrors[] = [
2245-
'message' => '#^Method CodeIgniter\\\\Validation\\\\ValidationInterface\\:\\:setRuleGroup\\(\\) has no return type specified\\.$#',
2246-
'count' => 1,
2247-
'path' => __DIR__ . '/system/Validation/ValidationInterface.php',
2248-
];
22492189
$ignoreErrors[] = [
22502190
'message' => '#^Call to an undefined static method CodeIgniter\\\\Config\\\\Factories\\:\\:cells\\(\\)\\.$#',
22512191
'count' => 1,

system/Security/Exceptions/SecurityException.php

+23
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,24 @@
1616

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

29+
/**
30+
* Throws when the source string contains invalid UTF-8 characters.
31+
*
32+
* @param string $source The source string
33+
* @param string $string The invalid string
34+
*
35+
* @return static
36+
*/
2437
public static function forInvalidUTF8Chars(string $source, string $string)
2538
{
2639
return new static(
@@ -29,6 +42,14 @@ public static function forInvalidUTF8Chars(string $source, string $string)
2942
);
3043
}
3144

45+
/**
46+
* Throws when the source string contains invalid control characters.
47+
*
48+
* @param string $source The source string
49+
* @param string $string The invalid string
50+
*
51+
* @return static
52+
*/
3253
public static function forInvalidControlChars(string $source, string $string)
3354
{
3455
return new static(
@@ -41,6 +62,8 @@ public static function forInvalidControlChars(string $source, string $string)
4162
* @deprecated Use `CookieException::forInvalidSameSite()` instead.
4263
*
4364
* @codeCoverageIgnore
65+
*
66+
* @return static
4467
*/
4568
public static function forInvalidSameSite(string $samesite)
4669
{

system/Validation/Exceptions/ValidationException.php

+25
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,51 @@
1515

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

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

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

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

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

system/Validation/Validation.php

+4
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,8 @@ public function getRuleGroup(string $group): array
593593
*
594594
* @param string $group Group.
595595
*
596+
* @return void
597+
*
596598
* @throws ValidationException If group not found.
597599
*/
598600
public function setRuleGroup(string $group)
@@ -645,6 +647,8 @@ public function showError(string $field, string $template = 'single'): string
645647
/**
646648
* Loads all of the rulesets classes that have been defined in the
647649
* Config\Validation and stores them locally so we can use them.
650+
*
651+
* @return void
648652
*/
649653
protected function loadRuleSets()
650654
{

system/Validation/ValidationInterface.php

+2
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ public function getRuleGroup(string $group): array;
9292
* Set rule group.
9393
*
9494
* @param string $group Group.
95+
*
96+
* @return void
9597
*/
9698
public function setRuleGroup(string $group);
9799

0 commit comments

Comments
 (0)