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 Honeypot and I18n ignore errors in phpstan-baseline.php #7770

Merged
merged 7 commits into from
Aug 8, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
50 changes: 0 additions & 50 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -1146,56 +1146,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Honeypot\\\\Exceptions\\\\HoneypotException\\:\\:forNoHiddenValue\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Honeypot/Exceptions/HoneypotException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Honeypot\\\\Exceptions\\\\HoneypotException\\:\\:forNoNameField\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Honeypot/Exceptions/HoneypotException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Honeypot\\\\Exceptions\\\\HoneypotException\\:\\:forNoTemplate\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Honeypot/Exceptions/HoneypotException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Honeypot\\\\Exceptions\\\\HoneypotException\\:\\:isBot\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Honeypot/Exceptions/HoneypotException.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Honeypot\\\\Honeypot\\:\\:attachHoneypot\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Honeypot/Honeypot.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Honeypot\\\\Honeypot\\:\\:hasContent\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Honeypot/Honeypot.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\I18n\\\\Time\\:\\:setTestNow\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/I18n/Time.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\I18n\\\\Time\\:\\:toDateTimeString\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/I18n/Time.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\I18n\\\\TimeLegacy\\:\\:setTestNow\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/I18n/TimeLegacy.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\I18n\\\\TimeLegacy\\:\\:toDateTimeString\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/I18n/TimeLegacy.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Images\\\\Handlers\\\\BaseHandler\\:\\:\\$image \\(CodeIgniter\\\\Images\\\\Image\\) in empty\\(\\) is not falsy\\.$#',
'count' => 1,
Expand Down
20 changes: 20 additions & 0 deletions system/Honeypot/Exceptions/HoneypotException.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,41 @@

class HoneypotException extends ConfigException implements ExceptionInterface
{
/**
* Thrown when the template value of config is empty.
*
* @return static
*/
public static function forNoTemplate()
{
return new static(lang('Honeypot.noTemplate'));
}

/**
* Thrown when the name value of config is empty.
*
* @return static
*/
public static function forNoNameField()
{
return new static(lang('Honeypot.noNameField'));
}

/**
* Thrown when the hidden value of config is false.
*
* @return static
*/
public static function forNoHiddenValue()
{
return new static(lang('Honeypot.noHiddenValue'));
}

/**
* Thrown when there are no data in the request of honeypot field.
*
* @return static
*/
public static function isBot()
{
return new static(lang('Honeypot.theClientIsABot'));
Expand Down
4 changes: 4 additions & 0 deletions system/Honeypot/Honeypot.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ public function __construct(HoneypotConfig $config)

/**
* Checks the request if honeypot field has data.
*
* @return bool
*/
public function hasContent(RequestInterface $request)
{
Expand All @@ -69,6 +71,8 @@ public function hasContent(RequestInterface $request)

/**
* Attaches Honeypot template to response.
*
* @return void
*/
public function attachHoneypot(ResponseInterface $response)
{
Expand Down
4 changes: 4 additions & 0 deletions system/I18n/TimeTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ public function toDateTime()
* @param DateTimeInterface|self|string|null $datetime
* @param DateTimeZone|string|null $timezone
*
* @return void
*
* @throws Exception
*/
public static function setTestNow($datetime = null, $timezone = null, ?string $locale = null)
Expand Down Expand Up @@ -845,6 +847,8 @@ public function subYears(int $years)
/**
* Returns the localized value of the date in the format 'Y-m-d H:i:s'
*
* @return false|string
*
* @throws Exception
*/
public function toDateTimeString()
Expand Down