Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Nov 9, 2023
1 parent 39f05ff commit 626151c
Show file tree
Hide file tree
Showing 10 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Builder/GroupBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
final class GroupBuilder implements RoutableInterface
{
/**
* @var Group[]|Route[]|RoutableInterface[]
* @var Group[]|RoutableInterface[]|Route[]
*/
private array $routes = [];

Expand Down
4 changes: 1 addition & 3 deletions src/Builder/RouteBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@
use Yiisoft\Router\RoutableInterface;
use Yiisoft\Router\Route;

use function in_array;

/**
* Route defines a mapping from URL to callback / name and vice versa.
*/
Expand All @@ -20,7 +18,7 @@ final class RouteBuilder implements RoutableInterface
private ?string $name = null;

/**
* @var array|string|callable|null
* @var array|callable|string|null
*/
private $action = null;

Expand Down
4 changes: 2 additions & 2 deletions src/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
final class Group
{
/**
* @var Group[]|Route[]|RoutableInterface[]
* @var Group[]|RoutableInterface[]|Route[]
*/
private array $routes = [];

Expand Down Expand Up @@ -195,7 +195,7 @@ private function assertMiddlewares(array $middlewares): void
*/
private function assertRoutes(array $routes): void
{
/** @var Route|Group|RoutableInterface $route */
/** @var Group|RoutableInterface|Route $route */
foreach ($routes as $route) {

Check warning on line 199 in src/Group.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "Foreach_": --- Original +++ New @@ @@ private function assertRoutes(array $routes) : void { /** @var Group|RoutableInterface|Route $route */ - foreach ($routes as $route) { + foreach (array() as $route) { if ($route instanceof Route || $route instanceof self || $route instanceof RoutableInterface) { continue; }

Check warning on line 199 in src/Group.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "Foreach_": --- Original +++ New @@ @@ private function assertRoutes(array $routes) : void { /** @var Group|RoutableInterface|Route $route */ - foreach ($routes as $route) { + foreach (array() as $route) { if ($route instanceof Route || $route instanceof self || $route instanceof RoutableInterface) { continue; }
if ($route instanceof Route || $route instanceof self || $route instanceof RoutableInterface) {

Check warning on line 200 in src/Group.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "LogicalOr": --- Original +++ New @@ @@ { /** @var Group|RoutableInterface|Route $route */ foreach ($routes as $route) { - if ($route instanceof Route || $route instanceof self || $route instanceof RoutableInterface) { + if ($route instanceof Route && $route instanceof self || $route instanceof RoutableInterface) { continue; } throw new \InvalidArgumentException('Invalid $routes provided, array of `Route` or `Group` or `RoutableInterface` instance expected.');

Check warning on line 200 in src/Group.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "LogicalOr": --- Original +++ New @@ @@ { /** @var Group|RoutableInterface|Route $route */ foreach ($routes as $route) { - if ($route instanceof Route || $route instanceof self || $route instanceof RoutableInterface) { + if ($route instanceof Route && $route instanceof self || $route instanceof RoutableInterface) { continue; } throw new \InvalidArgumentException('Invalid $routes provided, array of `Route` or `Group` or `RoutableInterface` instance expected.');
continue;

Check warning on line 201 in src/Group.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "Continue_": --- Original +++ New @@ @@ /** @var Group|RoutableInterface|Route $route */ foreach ($routes as $route) { if ($route instanceof Route || $route instanceof self || $route instanceof RoutableInterface) { - continue; + break; } throw new \InvalidArgumentException('Invalid $routes provided, array of `Route` or `Group` or `RoutableInterface` instance expected.'); } } }

Check warning on line 201 in src/Group.php

View workflow job for this annotation

GitHub Actions / mutation / PHP 8.1-ubuntu-latest

Escaped Mutant for Mutator "Continue_": --- Original +++ New @@ @@ /** @var Group|RoutableInterface|Route $route */ foreach ($routes as $route) { if ($route instanceof Route || $route instanceof self || $route instanceof RoutableInterface) { - continue; + break; } throw new \InvalidArgumentException('Invalid $routes provided, array of `Route` or `Group` or `RoutableInterface` instance expected.'); } } }
Expand Down
4 changes: 1 addition & 3 deletions src/RouteCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
use Psr\Http\Message\ResponseFactoryInterface;
use Yiisoft\Http\Method;

use Yiisoft\Router\Builder\RouteBuilder;

use function array_key_exists;
use function in_array;
use function is_array;
Expand Down Expand Up @@ -67,7 +65,7 @@ private function ensureItemsInjected(): void
/**
* Build routes array.
*
* @param Group[]|Route[]|RoutableInterface[] $items
* @param Group[]|RoutableInterface[]|Route[] $items
*/
private function injectItems(array $items): void
{
Expand Down
2 changes: 1 addition & 1 deletion src/RouteCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
final class RouteCollector implements RouteCollectorInterface
{
/**
* @var Group[]|Route[]|RoutableInterface[]
* @var Group[]|RoutableInterface[]|Route[]
*/
private array $items = [];

Expand Down
2 changes: 1 addition & 1 deletion src/RouteCollectorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function middleware(array|callable|string ...$definition): self;
public function prependMiddleware(array|callable|string ...$definition): self;

/**
* @return Group[]|Route[]|RoutableInterface[]
* @return Group[]|RoutableInterface[]|Route[]
*/
public function getItems(): array;

Expand Down
1 change: 0 additions & 1 deletion tests/Builder/GroupBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ public function testName(): void
$this->assertSame('api', $group->toRoute()->getNamePrefix());
}


public function testWithCors(): void
{
$group = Group::create()
Expand Down
1 change: 0 additions & 1 deletion tests/Builder/RouteBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
use Psr\Http\Server\RequestHandlerInterface;
use RuntimeException;
use Yiisoft\Http\Method;
use Yiisoft\Middleware\Dispatcher\MiddlewareDispatcher;
use Yiisoft\Middleware\Dispatcher\MiddlewareFactory;
Expand Down
1 change: 0 additions & 1 deletion tests/Debug/RouterCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
use Yiisoft\Router\Builder\GroupBuilder;
use Yiisoft\Router\Builder\RouteBuilder;
use Yiisoft\Router\Debug\RouterCollector;
use Yiisoft\Router\Group;
use Yiisoft\Router\Route;
use Yiisoft\Router\RouteCollection;
use Yiisoft\Router\RouteCollectionInterface;
Expand Down
2 changes: 1 addition & 1 deletion tests/GroupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public function testSetMiddlewaresAfterGetEnabledMiddlewares(): void

public function testDisableMiddlewareAfterGetEnabledMiddlewares(): void
{
$group = (new Group)
$group = (new Group())
->setMiddlewares([TestMiddleware1::class, TestMiddleware2::class, TestMiddleware3::class]);

$group->getEnabledMiddlewares();
Expand Down

0 comments on commit 626151c

Please sign in to comment.