Skip to content

Commit

Permalink
refactor: Fix phpstan return.type (#9375)
Browse files Browse the repository at this point in the history
* refactor: Fix phpstan return.type

* refactor: Fix phpstan return.type
  • Loading branch information
neznaika0 authored Jan 8, 2025
1 parent 3eb8a09 commit 72b7f8a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
26 changes: 24 additions & 2 deletions tests/system/Commands/Utilities/Routes/FilterFinderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use CodeIgniter\HTTP\IncomingRequest;
use CodeIgniter\HTTP\Response;
use CodeIgniter\Router\RouteCollection;
use CodeIgniter\Router\RouteCollectionInterface;
use CodeIgniter\Router\Router;
use CodeIgniter\Test\CIUnitTestCase;
use CodeIgniter\Test\ConfigFromArrayTrait;
Expand Down Expand Up @@ -53,7 +54,7 @@ protected function setUp(): void
$this->moduleConfig->enabled = false;
}

private function createRouteCollection(array $routes = []): RouteCollection
private function createRouteCollection(array $routes = []): RouteCollectionInterface
{
$collection = new RouteCollection(service('locator'), $this->moduleConfig, new Routing());

Expand All @@ -66,7 +67,7 @@ private function createRouteCollection(array $routes = []): RouteCollection
return $collection->map($routes);
}

private function createRouter(RouteCollection $collection): Router
private function createRouter(RouteCollectionInterface $collection): Router
{
return new Router($collection, $this->request);
}
Expand Down Expand Up @@ -101,6 +102,9 @@ private function createFilters(array $config = []): Filters

public function testFindGlobalsFilters(): void
{
/**
* @var RouteCollection $collection
*/
$collection = $this->createRouteCollection();
$router = $this->createRouter($collection);
$filters = $this->createFilters();
Expand All @@ -118,6 +122,9 @@ public function testFindGlobalsFilters(): void

public function testFindGlobalsFiltersWithRedirectRoute(): void
{
/**
* @var RouteCollection $collection
*/
$collection = $this->createRouteCollection();
$collection->addRedirect('users/about', 'profile');

Expand All @@ -137,6 +144,9 @@ public function testFindGlobalsFiltersWithRedirectRoute(): void

public function testFindGlobalsAndRouteFilters(): void
{
/**
* @var RouteCollection $collection
*/
$collection = $this->createRouteCollection();
$collection->get('admin', ' AdminController::index', ['filter' => 'honeypot']);
$router = $this->createRouter($collection);
Expand All @@ -155,6 +165,9 @@ public function testFindGlobalsAndRouteFilters(): void

public function testFindGlobalsAndRouteClassnameFilters(): void
{
/**
* @var RouteCollection $collection
*/
$collection = $this->createRouteCollection();
$collection->get('admin', ' AdminController::index', ['filter' => InvalidChars::class]);
$router = $this->createRouter($collection);
Expand All @@ -173,6 +186,9 @@ public function testFindGlobalsAndRouteClassnameFilters(): void

public function testFindGlobalsAndRouteMultipleFilters(): void
{
/**
* @var RouteCollection $collection
*/
$collection = $this->createRouteCollection();
$collection->get('admin', ' AdminController::index', ['filter' => ['honeypot', InvalidChars::class]]);
$router = $this->createRouter($collection);
Expand All @@ -191,6 +207,9 @@ public function testFindGlobalsAndRouteMultipleFilters(): void

public function testFilterOrder(): void
{
/**
* @var RouteCollection $collection
*/
$collection = $this->createRouteCollection([]);
$collection->get('/', ' Home::index', ['filter' => ['route1', 'route2']]);
$router = $this->createRouter($collection);
Expand Down Expand Up @@ -256,6 +275,9 @@ public function testFilterOrderWithOldFilterOrder(): void
$feature = config(Feature::class);
$feature->oldFilterOrder = true;

/**
* @var RouteCollection $collection
*/
$collection = $this->createRouteCollection([]);
$collection->get('/', ' Home::index', ['filter' => ['route1', 'route2']]);
$router = $this->createRouter($collection);
Expand Down
1 change: 0 additions & 1 deletion utils/phpstan-baseline/loader.neon
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ includes:
- property.readOnlyByPhpDocDefaultValue.neon
- property.unusedType.neon
- return.missing.neon
- return.type.neon
- return.unusedType.neon
- staticMethod.notFound.neon
- ternary.shortNotAllowed.neon
Expand Down
8 changes: 0 additions & 8 deletions utils/phpstan-baseline/return.type.neon

This file was deleted.

0 comments on commit 72b7f8a

Please sign in to comment.