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

Bug: warning in Routes.php #3369

Closed
gmeister2 opened this issue Jul 21, 2020 · 7 comments · Fixed by #3371
Closed

Bug: warning in Routes.php #3369

gmeister2 opened this issue Jul 21, 2020 · 7 comments · Fixed by #3371
Labels
bug Verified issues on the current code behavior or pull requests that will fix them

Comments

@gmeister2
Copy link

Describe the bug
When using the group function in Routes.php, example:
$routes->group('api', ['namespace' => 'App\API\v1'], function($routes)
{
$routes->resource('users');
});

PhpStorm gives the following warning:
Expected parameter of type 'array|array[]', 'Closure' provided

CodeIgniter 4 version
CI 4.04

Affected module(s)
app\Config\Routes.php

Expected behavior, and steps to reproduce if appropriate
CI 4.03 did not show this warning, because of difference in DocBlock of 'group' function in:
vendor\codeigniter4\framework\system\Router\RouteCollection.php

@gmeister2 gmeister2 added the bug Verified issues on the current code behavior or pull requests that will fix them label Jul 21, 2020
@gmeister2 gmeister2 changed the title Bug: Bug: warning in Routes.php Jul 21, 2020
@bagimuka
Copy link
Contributor

$routes->group('/', [
'namespace' => 'App\Controllers\API\v1''
], function($routes) {

$routes->resource('users');

});

put that in controller folder.. and use name space in ur controller

@gmeister2
Copy link
Author

gmeister2 commented Jul 21, 2020

I took the example from the CI User Guide. My application works fine, I just wanted to report the warning given by PhpStorm.

@paulbalandan
Copy link
Member

@gmeister2 I made the PR for the docblock changes of RouterCollection and did not know that PhpStorm resolves docblocks that way. I am using VSCode as my IDE and no warnings were generated using your example. Can you try using mixed as typehint if it will be removed?

@gmeister2
Copy link
Author

Yes, this solves it for me.
line 729: @param mixed ...$params

@paulbalandan
Copy link
Member

OK, I'll PR that.

@gmeister2
Copy link
Author

Thanks!

@vitalijalbu
Copy link

I have the same problem, please help. Thanks.

carbon-1
Schermata 2020-09-22 alle 14 58 38

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Verified issues on the current code behavior or pull requests that will fix them
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants