diff --git a/composer.json b/composer.json index 754b9fc..b4151b0 100644 --- a/composer.json +++ b/composer.json @@ -7,7 +7,7 @@ } }, "require": { - "php": ">=7.2", + "php": ">=7.4", "psr/http-message": "^1.0" }, "suggest": { @@ -30,6 +30,9 @@ }, "config": { "sort-packages": true, - "process-timeout": 600 + "process-timeout": 600, + "allow-plugins": { + "dealerdirect/phpcodesniffer-composer-installer": true + } } } diff --git a/src/Bridge/Slim/SlimRoute.php b/src/Bridge/Slim/SlimRoute.php index 307b22e..9e99316 100644 --- a/src/Bridge/Slim/SlimRoute.php +++ b/src/Bridge/Slim/SlimRoute.php @@ -37,4 +37,10 @@ public function getCallable(): callable return $this->route->getCallable(); } + + + public function getName(): ?string + { + return $this->route->getName(); + } } diff --git a/src/Bridge/Slim/SlimRouterNetteDiFactory.php b/src/Bridge/Slim/SlimRouterNetteDiFactory.php index 78c60d8..661f613 100644 --- a/src/Bridge/Slim/SlimRouterNetteDiFactory.php +++ b/src/Bridge/Slim/SlimRouterNetteDiFactory.php @@ -58,14 +58,12 @@ private static function createSlimRouter(Container $container, array $routes): R throw new LogicException(sprintf('Route with pattern: "%s" must have name.', $pattern)); } - $callbackProvider = function () use ($container, $data) { - return self::getService($container, $data['service']); - }; + $callbackProvider = fn() => self::getService($container, $data['service']); $route = $router->map( explode(self::METHOD_DELIMITER, $method), $pattern, - new RouteCallbackAccessor($callbackProvider) + new RouteCallbackAccessor($callbackProvider), ); $route->setName($data['name']); } diff --git a/src/Bridge/Slim/SlimRouterTest.php b/src/Bridge/Slim/SlimRouterTest.php index 8d8790e..f48dc6e 100644 --- a/src/Bridge/Slim/SlimRouterTest.php +++ b/src/Bridge/Slim/SlimRouterTest.php @@ -18,7 +18,7 @@ public function testPathFor(): void ['GET'], '/foo/{foo}/bar/{bar}', function (): void { - } + }, ); $route->setName('fooRoute'); $router = new SlimRouter($slimRouter); diff --git a/src/Route.php b/src/Route.php index 91c4a49..6868e5a 100644 --- a/src/Route.php +++ b/src/Route.php @@ -13,4 +13,7 @@ public function getArgument(string $name, $default = null); public function getCallable(): callable; + + + public function getName(): ?string; }