@@ -85,7 +85,7 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | public function createInvalidResponseFactory(): callable |
| 87 | 87 | { |
| 88 | - return function (): void { |
|
| 88 | + return function(): void { |
|
| 89 | 89 | Assert::fail('Response generated when it should not have been'); |
| 90 | 90 | }; |
| 91 | 91 | } |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | |
| 163 | 163 | $finalHandler = $this->prophesize(RequestHandlerInterface::class); |
| 164 | 164 | $finalHandler |
| 165 | - ->handle(Argument::that(function (ServerRequestInterface $request) use ($method) { |
|
| 165 | + ->handle(Argument::that(function(ServerRequestInterface $request) use ($method) { |
|
| 166 | 166 | Assert::assertSame($method, $request->getMethod()); |
| 167 | 167 | |
| 168 | 168 | $routeResult = $request->getAttribute(RouteResults::class); |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | public function testExplicitWithoutCollector(string $method, array $routes): void |
| 201 | 201 | { |
| 202 | 202 | $router = $this->getRouter(); |
| 203 | - [$serverRequest,] = $this->psrServerResponseFactory(); |
|
| 203 | + [$serverRequest, ] = $this->psrServerResponseFactory(); |
|
| 204 | 204 | |
| 205 | 205 | $finalHandler = $this->prophesize(RequestHandlerInterface::class); |
| 206 | 206 | $finalHandler->handle(Argument::any())->shouldNotBeCalled(); |
@@ -247,7 +247,7 @@ discard block |
||
| 247 | 247 | public function testWithoutImplicitMiddleware(string $requestMethod, array $allowedMethods): void |
| 248 | 248 | { |
| 249 | 249 | $router = $this->getRouteCollection(); |
| 250 | - [$serverRequest,] = $this->psrServerResponseFactory(); |
|
| 250 | + [$serverRequest, ] = $this->psrServerResponseFactory(); |
|
| 251 | 251 | |
| 252 | 252 | $finalResponse = $this->prophesize(ResponseInterface::class); |
| 253 | 253 | $finalResponse->withStatus(405)->will([$finalResponse, 'reveal']); |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | foreach ($allowedMethods as $routeMethod) { |
| 260 | 260 | $route = (new Route([$routeMethod], '/api/v1/me', $finalHandler->reveal())) |
| 261 | 261 | ->addMiddleware( |
| 262 | - function (ServerRequestInterface $request, RequestHandlerInterface $handler) { |
|
| 262 | + function(ServerRequestInterface $request, RequestHandlerInterface $handler) { |
|
| 263 | 263 | return $handler->handle($request); |
| 264 | 264 | } |
| 265 | 265 | ); |
@@ -329,11 +329,11 @@ discard block |
||
| 329 | 329 | ->willReturn($finalResponse) |
| 330 | 330 | ->shouldBeCalledTimes(1); |
| 331 | 331 | |
| 332 | - $router->map([$requestMethod], $routePath, function () use ($finalResponse) { |
|
| 332 | + $router->map([$requestMethod], $routePath, function() use ($finalResponse) { |
|
| 333 | 333 | return $finalResponse; |
| 334 | 334 | }) |
| 335 | 335 | ->addMiddleware( |
| 336 | - function (ServerRequestInterface $req, RequestHandlerInterface $handle) use ($middleware, $requestMethod) { |
|
| 336 | + function(ServerRequestInterface $req, RequestHandlerInterface $handle) use ($middleware, $requestMethod) { |
|
| 337 | 337 | Assert::assertEquals($requestMethod, $req->getMethod()); |
| 338 | 338 | Assert::assertInstanceOf(Next::class, $handle); |
| 339 | 339 | |
@@ -374,7 +374,7 @@ discard block |
||
| 374 | 374 | array $asserts = [] |
| 375 | 375 | ): void { |
| 376 | 376 | $router = $this->getRouteCollection(); |
| 377 | - [$serverRequest,] = $this->psrServerResponseFactory(); |
|
| 377 | + [$serverRequest, ] = $this->psrServerResponseFactory(); |
|
| 378 | 378 | |
| 379 | 379 | $router->map([$requestMethod], $routePath, $controller) |
| 380 | 380 | ->setName($routeOptions['name'] ?? null) |
@@ -478,10 +478,10 @@ discard block |
||
| 478 | 478 | $router = $this->getRouteCollection(); |
| 479 | 479 | $router->setNamespace('Flight\\Routing\\Tests\\'); |
| 480 | 480 | |
| 481 | - [$serverRequest,] = $this->psrServerResponseFactory(); |
|
| 481 | + [$serverRequest, ] = $this->psrServerResponseFactory(); |
|
| 482 | 482 | $path = $serverRequest->getUri()->withPath('/' . ($asserts['path'] ?? 'group/test')); |
| 483 | 483 | |
| 484 | - $router->group($groupAttributes, function (RouterProxyInterface $route) use ($asserts): void { |
|
| 484 | + $router->group($groupAttributes, function(RouterProxyInterface $route) use ($asserts): void { |
|
| 485 | 485 | $route->get( |
| 486 | 486 | 'test*<homePageRequestResponse>', |
| 487 | 487 | isset($asserts['namespace']) ? 'SampleController' : SampleController::class |
@@ -515,9 +515,9 @@ discard block |
||
| 515 | 515 | public function testImplicitRouteNotFound(): void |
| 516 | 516 | { |
| 517 | 517 | $router = $this->getRouteCollection(); |
| 518 | - [$serverRequest,] = $this->psrServerResponseFactory(); |
|
| 518 | + [$serverRequest, ] = $this->psrServerResponseFactory(); |
|
| 519 | 519 | |
| 520 | - $router->map([HttpMethods::METHOD_GET], '/error', function () { |
|
| 520 | + $router->map([HttpMethods::METHOD_GET], '/error', function() { |
|
| 521 | 521 | return 'This is an error page'; |
| 522 | 522 | })->setName('error'); |
| 523 | 523 | |
@@ -43,7 +43,7 @@ discard block |
||
| 43 | 43 | '/', |
| 44 | 44 | '/', |
| 45 | 45 | HttpMethods::METHOD_GET, |
| 46 | - function () { |
|
| 46 | + function() { |
|
| 47 | 47 | return 'Hello World'; |
| 48 | 48 | }, |
| 49 | 49 | [], |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | '/', |
| 55 | 55 | '/', |
| 56 | 56 | HttpMethods::METHOD_GET, |
| 57 | - function () { |
|
| 57 | + function() { |
|
| 58 | 58 | return '<html><body><h1>Hello World</h1></body></html>'; |
| 59 | 59 | }, |
| 60 | 60 | [ |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | '/', |
| 72 | 72 | '/', |
| 73 | 73 | HttpMethods::METHOD_GET, |
| 74 | - function () { |
|
| 74 | + function() { |
|
| 75 | 75 | return '<?xml version="1.0" encoding="UTF-8"?><route>Hello World</route>'; |
| 76 | 76 | }, |
| 77 | 77 | [], |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | '/', |
| 83 | 83 | '/', |
| 84 | 84 | HttpMethods::METHOD_GET, |
| 85 | - function () { |
|
| 85 | + function() { |
|
| 86 | 86 | return new Helpers\DumpArrayTest(); |
| 87 | 87 | }, |
| 88 | 88 | [], |
@@ -114,7 +114,7 @@ discard block |
||
| 114 | 114 | '/test', |
| 115 | 115 | '/test', |
| 116 | 116 | HttpMethods::METHOD_GET, |
| 117 | - function () { |
|
| 117 | + function() { |
|
| 118 | 118 | return 'Hello, this is a basic test route'; |
| 119 | 119 | }, |
| 120 | 120 | ]; |
@@ -123,7 +123,7 @@ discard block |
||
| 123 | 123 | '/test', |
| 124 | 124 | '/test/', |
| 125 | 125 | HttpMethods::METHOD_GET, |
| 126 | - function () { |
|
| 126 | + function() { |
|
| 127 | 127 | return 'Hello, this is a basic test route'; |
| 128 | 128 | }, |
| 129 | 129 | [], |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | '/test/{home}', |
| 135 | 135 | '/test/cool', |
| 136 | 136 | HttpMethods::METHOD_GET, |
| 137 | - function (string $home) { |
|
| 137 | + function(string $home) { |
|
| 138 | 138 | return 'Hello, this is a basic test route on subpage ' . $home; |
| 139 | 139 | }, |
| 140 | 140 | ]; |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | '/test/{home}', |
| 144 | 144 | '/test/cool', |
| 145 | 145 | HttpMethods::METHOD_GET, |
| 146 | - function (string $home, int $id) { |
|
| 146 | + function(string $home, int $id) { |
|
| 147 | 147 | return $home . $id; |
| 148 | 148 | }, |
| 149 | 149 | ['defaults' => ['id' => 233]], |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | '/test[/{home}]', |
| 155 | 155 | '/test', |
| 156 | 156 | HttpMethods::METHOD_GET, |
| 157 | - function (?string $home) { |
|
| 157 | + function(?string $home) { |
|
| 158 | 158 | return 'Hello, this is a basic test route on subpage ' . $home; |
| 159 | 159 | }, |
| 160 | 160 | [], |
@@ -165,7 +165,7 @@ discard block |
||
| 165 | 165 | '/test[/{home}]', |
| 166 | 166 | '/test/cool', |
| 167 | 167 | HttpMethods::METHOD_GET, |
| 168 | - function (?string $home) { |
|
| 168 | + function(?string $home) { |
|
| 169 | 169 | return 'Hello, this is a basic test route on subpage ' . $home; |
| 170 | 170 | }, |
| 171 | 171 | [], |
@@ -176,7 +176,7 @@ discard block |
||
| 176 | 176 | '//example.com/test', |
| 177 | 177 | '/test', |
| 178 | 178 | HttpMethods::METHOD_GET, |
| 179 | - function () { |
|
| 179 | + function() { |
|
| 180 | 180 | return 'Hello World'; |
| 181 | 181 | }, |
| 182 | 182 | ['domain' => 'example.com'], |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | '//{id:int}.example.com/test', |
| 187 | 187 | '/test', |
| 188 | 188 | HttpMethods::METHOD_GET, |
| 189 | - function () { |
|
| 189 | + function() { |
|
| 190 | 190 | return 'Hello World'; |
| 191 | 191 | }, |
| 192 | 192 | [ |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | 'https://{id:int}.example.com/{action}', |
| 202 | 202 | '/tests', |
| 203 | 203 | HttpMethods::METHOD_GET, |
| 204 | - function (string $action) { |
|
| 204 | + function(string $action) { |
|
| 205 | 205 | return 'Hello World' . $action; |
| 206 | 206 | }, |
| 207 | 207 | [ |
@@ -220,7 +220,7 @@ discard block |
||
| 220 | 220 | '/[{action}/[{id}]]', |
| 221 | 221 | '/test/', |
| 222 | 222 | HttpMethods::METHOD_GET, |
| 223 | - function (?string $action) { |
|
| 223 | + function(?string $action) { |
|
| 224 | 224 | return $action; |
| 225 | 225 | }, |
| 226 | 226 | [], |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | '/[{action}/[{id}]]', |
| 232 | 232 | '/test/id', |
| 233 | 233 | HttpMethods::METHOD_GET, |
| 234 | - function (?string $action) { |
|
| 234 | + function(?string $action) { |
|
| 235 | 235 | return $action; |
| 236 | 236 | }, |
| 237 | 237 | [ |
@@ -248,7 +248,7 @@ discard block |
||
| 248 | 248 | '/user/{id:[0-9-]+}', |
| 249 | 249 | 'user/23', |
| 250 | 250 | HttpMethods::METHOD_GET, |
| 251 | - function (int $id) { |
|
| 251 | + function(int $id) { |
|
| 252 | 252 | return $id; |
| 253 | 253 | }, |
| 254 | 254 | ]; |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | '/[{lang:[a-z]{2}}/]hello', |
| 258 | 258 | '/hello', |
| 259 | 259 | HttpMethods::METHOD_GET, |
| 260 | - function (?string $lang) { |
|
| 260 | + function(?string $lang) { |
|
| 261 | 261 | return $lang; |
| 262 | 262 | }, |
| 263 | 263 | ]; |
@@ -266,7 +266,7 @@ discard block |
||
| 266 | 266 | '/[{lang:[a-z]{2}}/]{name}', |
| 267 | 267 | '/en/download', |
| 268 | 268 | HttpMethods::METHOD_GET, |
| 269 | - function (?string $lang, string $name) { |
|
| 269 | + function(?string $lang, string $name) { |
|
| 270 | 270 | return $lang . $name; |
| 271 | 271 | }, |
| 272 | 272 | ]; |
@@ -275,7 +275,7 @@ discard block |
||
| 275 | 275 | '[{lang:[a-z]{2}}[-{sublang}]/]{name}[/page-{page=<0>}]', |
| 276 | 276 | '/download', |
| 277 | 277 | HttpMethods::METHOD_GET, |
| 278 | - function (?string $lang, ?string $sublang, string $name, $page) { |
|
| 278 | + function(?string $lang, ?string $sublang, string $name, $page) { |
|
| 279 | 279 | return $lang . '-' . $sublang . $name . $page; |
| 280 | 280 | }, |
| 281 | 281 | [], |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | '[{lang:[a-z]{2}}[-{sublang}]/]{name}[/page-{page=<0>}]', |
| 287 | 287 | '/en-us/download', |
| 288 | 288 | HttpMethods::METHOD_GET, |
| 289 | - function (?string $lang, ?string $sublang, string $name, $page) { |
|
| 289 | + function(?string $lang, ?string $sublang, string $name, $page) { |
|
| 290 | 290 | return $lang . '-' . $sublang . $name . $page; |
| 291 | 291 | }, |
| 292 | 292 | [], |
@@ -297,7 +297,7 @@ discard block |
||
| 297 | 297 | '[{lang:[a-z]{2}}[-{sublang}]/]{name}[/page-{page=<0>}]', |
| 298 | 298 | '/en-us/download/page-12', |
| 299 | 299 | HttpMethods::METHOD_GET, |
| 300 | - function (?string $lang, ?string $sublang, string $name, $page) { |
|
| 300 | + function(?string $lang, ?string $sublang, string $name, $page) { |
|
| 301 | 301 | return $lang . '-' . $sublang . $name . $page; |
| 302 | 302 | }, |
| 303 | 303 | [], |
@@ -519,7 +519,7 @@ discard block |
||
| 519 | 519 | { |
| 520 | 520 | return \array_filter( |
| 521 | 521 | \array_replace($middlewares, $this->getMiddlewaresStack()), |
| 522 | - function ($middleware) { |
|
| 522 | + function($middleware) { |
|
| 523 | 523 | return !\in_array($middleware, ['off', 'disable'], true); |
| 524 | 524 | } |
| 525 | 525 | ); |
@@ -600,7 +600,7 @@ discard block |
||
| 600 | 600 | private function checkForDuplicateRoute(string $path, array $methods): void |
| 601 | 601 | { |
| 602 | 602 | $allowed = []; |
| 603 | - $matches = \array_filter($this->getRoutes(), function (Route $route) use ($path, $methods, $allowed) { |
|
| 603 | + $matches = \array_filter($this->getRoutes(), function(Route $route) use ($path, $methods, $allowed) { |
|
| 604 | 604 | if ($path === $route->getPath()) { |
| 605 | 605 | foreach ($methods as $method) { |
| 606 | 606 | if (\in_array($method, $route->getMethods(), true)) { |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | |
| 57 | 57 | // Match domain + scheme from pattern... |
| 58 | 58 | if (\preg_match('@^(?:(https?):)?(//[^/]+)@i', $pattern)) { |
| 59 | - $pattern = \preg_replace_callback('@^(?:(https?):)?(//[^/]+)@i', function ($matches) { |
|
| 59 | + $pattern = \preg_replace_callback('@^(?:(https?):)?(//[^/]+)@i', function($matches) { |
|
| 60 | 60 | $this->addDomain(isset($matches[1]) ? $matches[0] : $matches[2]); |
| 61 | 61 | |
| 62 | 62 | return ''; |
@@ -110,7 +110,7 @@ |
||
| 110 | 110 | */ |
| 111 | 111 | public function handle(callable $controller, CallableResolverInterface $callableResolver): callable |
| 112 | 112 | { |
| 113 | - $finalController = function (Request $request, Response $response) use ($controller, $callableResolver) { |
|
| 113 | + $finalController = function(Request $request, Response $response) use ($controller, $callableResolver) { |
|
| 114 | 114 | if (\class_exists(BoundMethod::class)) { |
| 115 | 115 | return BoundMethod::call( |
| 116 | 116 | $container = $callableResolver->getContainer(), |
@@ -234,7 +234,7 @@ |
||
| 234 | 234 | */ |
| 235 | 235 | private function createDispatcherCallback(): callable |
| 236 | 236 | { |
| 237 | - return function (RouteInterface $route) { |
|
| 237 | + return function(RouteInterface $route) { |
|
| 238 | 238 | return (new SimpleRouteCompiler())->compile($route); |
| 239 | 239 | }; |
| 240 | 240 | } |