codeigniter4 / CodeIgniter4

Open Source PHP Framework (originally from EllisLab)
https://codeigniter.com/
MIT License
5.35k stars 1.9k forks source link

Bug: warning in Routes.php #3369

Closed gmeister2 closed 4 years ago

gmeister2 commented 4 years ago

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

bagimuka commented 4 years ago

$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 commented 4 years ago

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

paulbalandan commented 4 years ago

@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 commented 4 years ago

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

paulbalandan commented 4 years ago

OK, I'll PR that.

gmeister2 commented 4 years ago

Thanks!

vitalijalbu commented 4 years ago

I have the same problem, please help. Thanks.

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