Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev: Remove the Security and Validation ignore errors in phpstan-baseline.php #7772

Merged
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 0 additions & 60 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -1746,26 +1746,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Router/RouterInterface.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Security\\\\Exceptions\\\\SecurityException\\:\\:forDisallowedAction\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Security/Exceptions/SecurityException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Security\\\\Exceptions\\\\SecurityException\\:\\:forInvalidControlChars\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Security/Exceptions/SecurityException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Security\\\\Exceptions\\\\SecurityException\\:\\:forInvalidSameSite\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Security/Exceptions/SecurityException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Security\\\\Exceptions\\\\SecurityException\\:\\:forInvalidUTF8Chars\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Security/Exceptions/SecurityException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Session\\\\Exceptions\\\\SessionException\\:\\:forEmptySavepath\\(\\) has no return type specified\\.$#',
'count' => 1,
Expand Down Expand Up @@ -2531,51 +2511,11 @@
'count' => 1,
'path' => __DIR__ . '/system/Throttle/Throttler.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Validation\\\\Exceptions\\\\ValidationException\\:\\:forGroupNotArray\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/Exceptions/ValidationException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Validation\\\\Exceptions\\\\ValidationException\\:\\:forGroupNotFound\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/Exceptions/ValidationException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Validation\\\\Exceptions\\\\ValidationException\\:\\:forInvalidTemplate\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/Exceptions/ValidationException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Validation\\\\Exceptions\\\\ValidationException\\:\\:forNoRuleSets\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/Exceptions/ValidationException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Validation\\\\Exceptions\\\\ValidationException\\:\\:forRuleNotFound\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/Exceptions/ValidationException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Validation\\\\Validation\\:\\:isClosure\\(\\) has parameter \\$rule with no signature specified for Closure\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/Validation.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Validation\\\\Validation\\:\\:loadRuleSets\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/Validation.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Validation\\\\Validation\\:\\:setRuleGroup\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/Validation.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Validation\\\\ValidationInterface\\:\\:setRuleGroup\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Validation/ValidationInterface.php',
];
$ignoreErrors[] = [
'message' => '#^Call to an undefined static method CodeIgniter\\\\Config\\\\Factories\\:\\:cells\\(\\)\\.$#',
'count' => 1,
Expand Down
23 changes: 23 additions & 0 deletions system/Security/Exceptions/SecurityException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,24 @@

class SecurityException extends FrameworkException implements HTTPExceptionInterface
{
/**
* Throws when some specific is not allowed.
paulbalandan marked this conversation as resolved.
Show resolved Hide resolved
*
* @return static
*/
public static function forDisallowedAction()
{
return new static(lang('Security.disallowedAction'), 403);
}

/**
* Throws when the source string contains invalid UTF-8 characters.
*
* @param string $source The source string
* @param string $string The invalid string
*
* @return static
*/
public static function forInvalidUTF8Chars(string $source, string $string)
{
return new static(
Expand All @@ -29,6 +42,14 @@ public static function forInvalidUTF8Chars(string $source, string $string)
);
}

/**
* Throws when the source string contains invalid control characters.
*
* @param string $source The source string
* @param string $string The invalid string
*
* @return static
*/
public static function forInvalidControlChars(string $source, string $string)
{
return new static(
Expand All @@ -41,6 +62,8 @@ public static function forInvalidControlChars(string $source, string $string)
* @deprecated Use `CookieException::forInvalidSameSite()` instead.
*
* @codeCoverageIgnore
*
* @return static
*/
public static function forInvalidSameSite(string $samesite)
{
Expand Down
25 changes: 25 additions & 0 deletions system/Validation/Exceptions/ValidationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,26 +15,51 @@

class ValidationException extends FrameworkException
{
/**
* Throws when the validation rule is not found.
*
* @return static
*/
public static function forRuleNotFound(?string $rule = null)
{
return new static(lang('Validation.ruleNotFound', [$rule]));
}

/**
* Throws when the group value of config is not isset.
paulbalandan marked this conversation as resolved.
Show resolved Hide resolved
*
* @return static
*/
public static function forGroupNotFound(?string $group = null)
{
return new static(lang('Validation.groupNotFound', [$group]));
}

/**
* Throws when the group value of config is not array type.
*
* @return static
*/
public static function forGroupNotArray(?string $group = null)
{
return new static(lang('Validation.groupNotArray', [$group]));
}

/**
* Throws when the template of config is invalid.
*
* @return static
*/
public static function forInvalidTemplate(?string $template = null)
{
return new static(lang('Validation.invalidTemplate', [$template]));
}

/**
* Throws when there is no any rule set.
*
* @return static
*/
public static function forNoRuleSets()
{
return new static(lang('Validation.noRuleSets'));
Expand Down
4 changes: 4 additions & 0 deletions system/Validation/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,8 @@ public function getRuleGroup(string $group): array
*
* @param string $group Group.
*
* @return void
*
* @throws ValidationException If group not found.
*/
public function setRuleGroup(string $group)
Expand Down Expand Up @@ -645,6 +647,8 @@ public function showError(string $field, string $template = 'single'): string
/**
* Loads all of the rulesets classes that have been defined in the
* Config\Validation and stores them locally so we can use them.
*
* @return void
*/
protected function loadRuleSets()
{
Expand Down
2 changes: 2 additions & 0 deletions system/Validation/ValidationInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ public function getRuleGroup(string $group): array;
* Set rule group.
*
* @param string $group Group.
*
* @return void
*/
public function setRuleGroup(string $group);

Expand Down