Skip to content

Commit

Permalink
Merge pull request #7770 from ping-yee/230804-phpstan-honeypot-i18n
Browse files Browse the repository at this point in the history
Dev: Remove the `Honeypot` and `I18n` ignore errors in phpstan-baseline.php
  • Loading branch information
kenjis authored Aug 8, 2023
2 parents 0e70713 + 163e1c4 commit e0a1094
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 50 deletions.
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

0 comments on commit e0a1094

Please sign in to comment.