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 Helpers ignore errors in phpstan-baseline.php #7777

Merged
merged 5 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
40 changes: 0 additions & 40 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -1246,51 +1246,11 @@
'count' => 1,
'path' => __DIR__ . '/system/HTTP/UserAgent.php',
];
$ignoreErrors[] = [
'message' => '#^Function delete_cookie\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Helpers/cookie_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Function set_cookie\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Helpers/cookie_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Right side of && is always true\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Helpers/filesystem_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Function d\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Helpers/kint_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Function d\\(\\) has parameter \\$vars with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Helpers/kint_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Function dd\\(\\) has no return type specified\\.$#',
'count' => 2,
'path' => __DIR__ . '/system/Helpers/kint_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Function dd\\(\\) has parameter \\$vars with no type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Helpers/kint_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Function trace\\(\\) has no return type specified\\.$#',
'count' => 2,
'path' => __DIR__ . '/system/Helpers/kint_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Function mock\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Helpers/test_helper.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Honeypot\\\\Exceptions\\\\HoneypotException\\:\\:forNoHiddenValue\\(\\) has no return type specified\\.$#',
'count' => 1,
Expand Down
4 changes: 4 additions & 0 deletions system/Helpers/cookie_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@
* @param bool|null $httpOnly True makes the cookie accessible via http(s) only (no javascript)
* @param string|null $sameSite The cookie SameSite value
*
* @return void
*
* @see \CodeIgniter\HTTP\Response::setCookie()
*/
function set_cookie(
Expand Down Expand Up @@ -91,6 +93,8 @@ function get_cookie($index, bool $xssClean = false, ?string $prefix = '')
* @param string $path the cookie path
* @param string $prefix the cookie prefix
*
* @return void
*
* @see \CodeIgniter\HTTP\Response::deleteCookie()
*/
function delete_cookie($name, string $domain = '', string $path = '/', string $prefix = '')
Expand Down
28 changes: 27 additions & 1 deletion system/Helpers/kint_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
/**
* Prints a Kint debug report and exits.
*
* @param array ...$vars
* @param array $vars
*
* @return void
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return void
* @return void
* @phpstan-return never

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please apply my suggested change.
The true return type is not void, but never.
See https://phpstan.org/writing-php-code/phpdoc-types#bottom-type
https://www.php.net/manual/en/language.types.never.php

*
* @codeCoverageIgnore Can't be tested ... exits
*/
Expand All @@ -31,6 +33,13 @@ function dd(...$vars)
}
} else {
// In case that Kint is not loaded.
/**
* dd function
*
* @param array $vars
*
* @return int
*/
function dd(...$vars)
{
return 0;
Expand All @@ -40,6 +49,13 @@ function dd(...$vars)

if (! function_exists('d') && ! class_exists(Kint::class)) {
// In case that Kint is not loaded.
/**
* d function
*
* @param array $vars
*
* @return int
*/
function d(...$vars)
{
return 0;
Expand All @@ -51,13 +67,23 @@ function d(...$vars)
/**
* Provides a backtrace to the current execution point, from Kint.
*/
/**
* trace function
*
* @return int
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @return int
* @return void

*/
function trace()
{
Kint::$aliases[] = 'trace';
Kint::trace();
}
} else {
// In case that Kint is not loaded.
/**
* trace function
*
* @return int
*/
function trace()
{
return 0;
Expand Down
2 changes: 2 additions & 0 deletions system/Helpers/test_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ function fake($model, ?array $overrides = null, $persist = true)
* Used within our test suite to mock certain system tools.
*
* @param string $className Fully qualified class name
*
* @return object
*/
function mock(string $className)
{
Expand Down