Skip to content

Commit f794bc9

Browse files
authored
refactor: fix iterable types in Router tests (#10488)
1 parent 6b8e12a commit f794bc9

7 files changed

Lines changed: 41 additions & 77 deletions

File tree

tests/system/Router/AutoRouterImprovedTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,6 +528,9 @@ public function testTranslateUriToCamelCase(
528528
], $router->getPos());
529529
}
530530

531+
/**
532+
* @return iterable<string, array{string, string|null, string, string, int, int|null, int|null}>
533+
*/
531534
public static function provideTranslateUriToCamelCase(): iterable
532535
{
533536
yield from [
@@ -587,6 +590,9 @@ public function testRejectTranslateUriToCamelCase(string $uri, string $expMsg):
587590
$router->getRoute($uri, Method::GET);
588591
}
589592

593+
/**
594+
* @return iterable<string, array{string, string}>
595+
*/
590596
public static function provideRejectTranslateUriToCamelCase(): iterable
591597
{
592598
yield from [

tests/system/Router/DefinedRouteCollectorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
#[Group('Others')]
2626
final class DefinedRouteCollectorTest extends CIUnitTestCase
2727
{
28+
/**
29+
* @param array<non-empty-string, list<non-empty-string>|non-empty-string> $config
30+
*/
2831
private function createRouteCollection(array $config = [], ?Modules $moduleConfig = null): RouteCollection
2932
{
3033
$defaults = [

tests/system/Router/RouteCollectionReverseRouteTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ protected function setUp(): void
3535
$this->resetFactories();
3636
}
3737

38+
/**
39+
* @param array<non-empty-string, list<non-empty-string>|non-empty-string> $config
40+
* @param array<array-key, mixed> $files
41+
*/
3842
protected function getCollector(array $config = [], array $files = [], ?Modules $moduleConfig = null): RouteCollection
3943
{
4044
$defaults = [
@@ -147,6 +151,9 @@ public function testReverseRoutingDefaultNamespaceAppController(string $controll
147151
$this->assertSame('/users/15/gallery12', $match);
148152
}
149153

154+
/**
155+
* @return iterable<string, array{string}>
156+
*/
150157
public static function provideReverseRoutingDefaultNamespaceAppController(): iterable
151158
{
152159
return yield from [

tests/system/Router/RouteCollectionTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ protected function setUp(): void
4444
Services::injectMock('superglobals', new Superglobals());
4545
}
4646

47+
/**
48+
* @param array<non-empty-string, list<non-empty-string>|non-empty-string> $config
49+
* @param array<array-key, mixed> $files
50+
*/
4751
protected function getCollector(array $config = [], array $files = [], ?Modules $moduleConfig = null): RouteCollection
4852
{
4953
$defaults = [
@@ -507,6 +511,9 @@ static function ($routes): void {
507511
$this->assertSame($expected, $routes->getRoutes());
508512
}
509513

514+
/**
515+
* @param array<string, string> $expected
516+
*/
510517
#[DataProvider('provideNestedGroupingWorksWithRootPrefix')]
511518
public function testNestedGroupingWorksWithRootPrefix(
512519
string $group,
@@ -531,6 +538,9 @@ static function ($routes): void {
531538
$this->assertSame($expected, $routes->getRoutes());
532539
}
533540

541+
/**
542+
* @return iterable<int, array{string, string, array<string, string>}>
543+
*/
534544
public static function provideNestedGroupingWorksWithRootPrefix(): iterable
535545
{
536546
yield from [
@@ -1343,6 +1353,10 @@ static function (): void {},
13431353
$this->assertSame($options, ['as' => 'admin', 'foo' => 'baz']);
13441354
}
13451355

1356+
/**
1357+
* @param array<string, string> $options1
1358+
* @param array<string, string> $options2
1359+
*/
13461360
#[DataProvider('provideRoutesOptionsWithSameFromTwoRoutes')]
13471361
public function testRoutesOptionsWithSameFromTwoRoutes(array $options1, array $options2): void
13481362
{
@@ -1366,6 +1380,9 @@ static function (): void {},
13661380
$this->assertSame($options, $options1);
13671381
}
13681382

1383+
/**
1384+
* @return iterable<int, array{array<string, string>, array<string, string>}>
1385+
*/
13691386
public static function provideRoutesOptionsWithSameFromTwoRoutes(): iterable
13701387
{
13711388
yield from [
@@ -1860,6 +1877,9 @@ public function testRoutesControllerNameReturnsFQCN(string $namespace): void
18601877
$this->assertSame('\\' . Product::class, $router->controllerName());
18611878
}
18621879

1880+
/**
1881+
* @return iterable<string, array{string}>
1882+
*/
18631883
public static function provideRouteDefaultNamespace(): iterable
18641884
{
18651885
return [

tests/system/Router/RouterTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -963,6 +963,9 @@ public function testRedirectRoute(
963963
$router->handle($url);
964964
}
965965

966+
/**
967+
* @return iterable<int, array{string, string, string, string, string, string}>
968+
*/
966969
public static function provideRedirectRoute(): iterable
967970
{
968971
// [$route, $redirectFrom, $redirectTo, $url, $expectedPath, $alias]

utils/phpstan-baseline/loader.neon

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 168 errors
1+
# total 153 errors
22

33
includes:
44
- argument.type.neon

utils/phpstan-baseline/missingType.iterableValue.neon

Lines changed: 1 addition & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# total 110 errors
1+
# total 95 errors
22

33
parameters:
44
ignoreErrors:
@@ -467,81 +467,6 @@ parameters:
467467
count: 1
468468
path: ../../tests/system/RESTful/ResourceControllerTest.php
469469

470-
-
471-
message: '#^Method CodeIgniter\\Router\\AutoRouterImprovedTest\:\:provideRejectTranslateUriToCamelCase\(\) return type has no value type specified in iterable type iterable\.$#'
472-
count: 1
473-
path: ../../tests/system/Router/AutoRouterImprovedTest.php
474-
475-
-
476-
message: '#^Method CodeIgniter\\Router\\AutoRouterImprovedTest\:\:provideTranslateUriToCamelCase\(\) return type has no value type specified in iterable type iterable\.$#'
477-
count: 1
478-
path: ../../tests/system/Router/AutoRouterImprovedTest.php
479-
480-
-
481-
message: '#^Method CodeIgniter\\Router\\DefinedRouteCollectorTest\:\:createRouteCollection\(\) has parameter \$config with no value type specified in iterable type array\.$#'
482-
count: 1
483-
path: ../../tests/system/Router/DefinedRouteCollectorTest.php
484-
485-
-
486-
message: '#^Method CodeIgniter\\Router\\RouteCollectionReverseRouteTest\:\:getCollector\(\) has parameter \$config with no value type specified in iterable type array\.$#'
487-
count: 1
488-
path: ../../tests/system/Router/RouteCollectionReverseRouteTest.php
489-
490-
-
491-
message: '#^Method CodeIgniter\\Router\\RouteCollectionReverseRouteTest\:\:getCollector\(\) has parameter \$files with no value type specified in iterable type array\.$#'
492-
count: 1
493-
path: ../../tests/system/Router/RouteCollectionReverseRouteTest.php
494-
495-
-
496-
message: '#^Method CodeIgniter\\Router\\RouteCollectionReverseRouteTest\:\:provideReverseRoutingDefaultNamespaceAppController\(\) return type has no value type specified in iterable type iterable\.$#'
497-
count: 1
498-
path: ../../tests/system/Router/RouteCollectionReverseRouteTest.php
499-
500-
-
501-
message: '#^Method CodeIgniter\\Router\\RouteCollectionTest\:\:getCollector\(\) has parameter \$config with no value type specified in iterable type array\.$#'
502-
count: 1
503-
path: ../../tests/system/Router/RouteCollectionTest.php
504-
505-
-
506-
message: '#^Method CodeIgniter\\Router\\RouteCollectionTest\:\:getCollector\(\) has parameter \$files with no value type specified in iterable type array\.$#'
507-
count: 1
508-
path: ../../tests/system/Router/RouteCollectionTest.php
509-
510-
-
511-
message: '#^Method CodeIgniter\\Router\\RouteCollectionTest\:\:provideNestedGroupingWorksWithRootPrefix\(\) return type has no value type specified in iterable type iterable\.$#'
512-
count: 1
513-
path: ../../tests/system/Router/RouteCollectionTest.php
514-
515-
-
516-
message: '#^Method CodeIgniter\\Router\\RouteCollectionTest\:\:provideRouteDefaultNamespace\(\) return type has no value type specified in iterable type iterable\.$#'
517-
count: 1
518-
path: ../../tests/system/Router/RouteCollectionTest.php
519-
520-
-
521-
message: '#^Method CodeIgniter\\Router\\RouteCollectionTest\:\:provideRoutesOptionsWithSameFromTwoRoutes\(\) return type has no value type specified in iterable type iterable\.$#'
522-
count: 1
523-
path: ../../tests/system/Router/RouteCollectionTest.php
524-
525-
-
526-
message: '#^Method CodeIgniter\\Router\\RouteCollectionTest\:\:testNestedGroupingWorksWithRootPrefix\(\) has parameter \$expected with no value type specified in iterable type array\.$#'
527-
count: 1
528-
path: ../../tests/system/Router/RouteCollectionTest.php
529-
530-
-
531-
message: '#^Method CodeIgniter\\Router\\RouteCollectionTest\:\:testRoutesOptionsWithSameFromTwoRoutes\(\) has parameter \$options1 with no value type specified in iterable type array\.$#'
532-
count: 1
533-
path: ../../tests/system/Router/RouteCollectionTest.php
534-
535-
-
536-
message: '#^Method CodeIgniter\\Router\\RouteCollectionTest\:\:testRoutesOptionsWithSameFromTwoRoutes\(\) has parameter \$options2 with no value type specified in iterable type array\.$#'
537-
count: 1
538-
path: ../../tests/system/Router/RouteCollectionTest.php
539-
540-
-
541-
message: '#^Method CodeIgniter\\Router\\RouterTest\:\:provideRedirectRoute\(\) return type has no value type specified in iterable type iterable\.$#'
542-
count: 1
543-
path: ../../tests/system/Router/RouterTest.php
544-
545470
-
546471
message: '#^Method CodeIgniter\\Throttle\\ThrottleTest\:\:provideTokenTimeCalculationUCs\(\) return type has no value type specified in iterable type iterable\.$#'
547472
count: 1

0 commit comments

Comments
 (0)