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

Apply PHP 7.4 syntax and typed property #21

Merged
merged 1 commit into from
Sep 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions src/LaminasRouter.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,30 +37,25 @@ class LaminasRouter implements RouterInterface

/**
* Store the HTTP methods allowed for each path.
*
* @var array
*/
private $allowedMethodsByPath = [];
private array $allowedMethodsByPath = [];

/**
* Map a named route to a Laminas route name to use for URI generation.
*
* @var array
*/
private $routeNameMap = [];
private array $routeNameMap = [];

/** @var Route[] */
private $routes = [];
private array $routes = [];

/**
* Routes aggregated to inject.
*
* @var Route[]
*/
private $routesToInject = [];
private array $routesToInject = [];

/** @var TreeRouteStack */
private $laminasRouter;
private TreeRouteStack $laminasRouter;

/**
* Lazy instantiates a TreeRouteStack if none is provided.
Expand Down
3 changes: 1 addition & 2 deletions test/LaminasRouter/ConfigProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@

class ConfigProviderTest extends TestCase
{
/** @var ConfigProvider */
private $provider;
private ConfigProvider $provider;

protected function setUp(): void
{
Expand Down
10 changes: 3 additions & 7 deletions test/LaminasRouterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class LaminasRouterTest extends TestCase
/** @var TreeRouteStack|ObjectProphecy */
private $laminasRouter;
/** @var Route[] */
private $routesToInject;
private ?array $routesToInject = null;

protected function setUp(): void
{
Expand All @@ -52,9 +52,7 @@ private function getMiddleware(): MiddlewareInterface
public function testWillLazyInstantiateALaminasTreeRouteStackIfNoneIsProvidedToConstructor(): void
{
$router = new LaminasRouter();
$laminasRouter = Closure::bind(function () {
return $this->laminasRouter;
}, $router, LaminasRouter::class)();
$laminasRouter = Closure::bind(fn() => $this->laminasRouter, $router, LaminasRouter::class)();
$this->assertInstanceOf(TreeRouteStack::class, $laminasRouter);
}

Expand Down Expand Up @@ -85,9 +83,7 @@ public function testAddingRouteAggregatesInRouter(): void
$router = $this->getRouter();
$router->addRoute($route);

$routesToInject = Closure::bind(function () {
return $this->routesToInject;
}, $router, LaminasRouter::class)();
$routesToInject = Closure::bind(fn() => $this->routesToInject, $router, LaminasRouter::class)();
$this->assertContains($route, $routesToInject);
}

Expand Down