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

Fix: Repair conflicts and emove the Debug ignore errors. #7801

Merged
merged 4 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 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
70 changes: 0 additions & 70 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -716,76 +716,6 @@
'count' => 1,
'path' => __DIR__ . '/system/Database/Seeder.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Exceptions\\:\\:exceptionHandler\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Exceptions.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Exceptions\\:\\:initialize\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Exceptions.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Exceptions\\:\\:render\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Exceptions.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Exceptions\\:\\:shutdownHandler\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Exceptions.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Iterator\\:\\:add\\(\\) has parameter \\$closure with no signature specified for Closure\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Iterator.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Timer\\:\\:record\\(\\) has parameter \\$callable with no signature specified for callable\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Timer.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Toolbar\\:\\:prepare\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Toolbar\\:\\:respond\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Toolbar\\\\Collectors\\\\BaseCollector\\:\\:getBadgeValue\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/BaseCollector.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Toolbar\\\\Collectors\\\\BaseCollector\\:\\:getVarData\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/BaseCollector.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Toolbar\\\\Collectors\\\\Database\\:\\:collect\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/Database.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Toolbar\\\\Collectors\\\\Database\\:\\:getConnections\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/Database.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Toolbar\\\\Collectors\\\\History\\:\\:setFiles\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/History.php',
];
$ignoreErrors[] = [
'message' => '#^Method CodeIgniter\\\\Debug\\\\Toolbar\\\\Collectors\\\\Logs\\:\\:collectLogs\\(\\) has no return type specified\\.$#',
'count' => 1,
'path' => __DIR__ . '/system/Debug/Toolbar/Collectors/Logs.php',
];
$ignoreErrors[] = [
'message' => '#^Property CodeIgniter\\\\Log\\\\Logger\\:\\:\\$logCache \\(array\\) on left side of \\?\\? is not nullable\\.$#',
'count' => 1,
Expand Down
12 changes: 12 additions & 0 deletions system/Debug/Exceptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ public function __construct(ExceptionsConfig $config, $request, ResponseInterfac
* handling of our application.
*
* @codeCoverageIgnore
*
* @return void
* @phpstan-return never|void
Copy link
Member

Choose a reason for hiding this comment

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

It seems never is not returned. See https://phpstan.org/writing-php-code/phpdoc-types#bottom-type

Suggested change
* @phpstan-return never|void

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed there to @phpstan-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.

If @return and @phpstan-return are the same, @phpstan-return is not needed.
Remove it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

*/
public function initialize()
{
Expand All @@ -112,6 +115,9 @@ public function initialize()
* and fire an event that allows custom actions to be taken at this point.
*
* @codeCoverageIgnore
*
* @return void
* @phpstan-return never|void
*/
public function exceptionHandler(Throwable $exception)
{
Expand Down Expand Up @@ -189,6 +195,9 @@ public function errorHandler(int $severity, string $message, ?string $file = nul
* need to be caught and handle them.
*
* @codeCoverageIgnore
*
* @return void
* @phpstan-return never|void
*/
public function shutdownHandler()
{
Expand Down Expand Up @@ -243,6 +252,9 @@ protected function determineView(Throwable $exception, string $templatePath): st

/**
* Given an exception and status code will display the error to the client.
*
* @return void
* @phpstan-return never|void
*/
protected function render(Throwable $exception, int $statusCode)
{
Expand Down
2 changes: 2 additions & 0 deletions system/Debug/Iterator.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ class Iterator
* Tests are simply closures that the user can define any sequence of
* things to happen during the test.
*
* @phpstan-param Closure(): mixed $closure
*
* @return $this
*/
public function add(string $name, Closure $closure)
Expand Down
4 changes: 2 additions & 2 deletions system/Debug/Timer.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public function has(string $name): bool
* Executes callable and measures its time.
* Returns its return value if any.
*
* @param string $name The name of the timer
* @param callable $callable callable to be executed
* @param string $name The name of the timer
* @phpstan-param callable(): mixed $callable callable to be executed
*
* @return array|bool|float|int|object|resource|string|null
*/
Expand Down
6 changes: 6 additions & 0 deletions system/Debug/Toolbar.php
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ protected function roundTo(float $number, int $increments = 5): float
*
* @param RequestInterface $request
* @param ResponseInterface $response
*
* @return void
* @phpstan-return never|void
Copy link
Member

Choose a reason for hiding this comment

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

Is there any exit() or die() in this method?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There does not include exit() or die().
So, I changed there to @phpstan-return void.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

*/
public function prepare(?RequestInterface $request = null, ?ResponseInterface $response = null)
{
Expand Down Expand Up @@ -434,6 +437,9 @@ public function prepare(?RequestInterface $request = null, ?ResponseInterface $r
* Inject debug toolbar into the response.
*
* @codeCoverageIgnore
*
* @return void
* @phpstan-return never|void
*/
public function respond()
{
Expand Down
4 changes: 4 additions & 0 deletions system/Debug/Toolbar/Collectors/BaseCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@ public function hasVarData(): bool
* 'bar' => 'baz'
* ],
* ];
*
* @return array|null
*/
public function getVarData()
{
Expand Down Expand Up @@ -183,6 +185,8 @@ public function cleanPath(string $file): string

/**
* Gets the "badge" value for the button.
*
* @return int|null
*/
public function getBadgeValue()
{
Expand Down
5 changes: 4 additions & 1 deletion system/Debug/Toolbar/Collectors/Database.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public function __construct()
* data.
*
* @internal
*
* @return void
* @phpstan-return never|void
*/
public static function collect(Query $query)
{
Expand Down Expand Up @@ -247,7 +250,7 @@ public function icon(): string
/**
* Gets the connections from the database config
*/
private function getConnections()
private function getConnections(): void
{
$this->connections = \Config\Database::getConnections();
}
Expand Down
2 changes: 2 additions & 0 deletions system/Debug/Toolbar/Collectors/History.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class History extends BaseCollector
*
* @param string $current Current history time
* @param int $limit Max history files
*
* @return void
*/
public function setFiles(string $current, int $limit = 20)
{
Expand Down
2 changes: 2 additions & 0 deletions system/Debug/Toolbar/Collectors/Logs.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ public function icon(): string

/**
* Ensures the data has been collected.
*
* @return array
*/
protected function collectLogs()
{
Expand Down