Skip to content

Commit

Permalink
Add more phpdoc
Browse files Browse the repository at this point in the history
  • Loading branch information
samdark committed Nov 22, 2020
1 parent f140091 commit 63acb32
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 2 deletions.
13 changes: 13 additions & 0 deletions src/MiddlewareDispatcher.php
Expand Up @@ -39,6 +39,19 @@ public function dispatch(ServerRequestInterface $request, RequestHandlerInterfac
return $this->stack->handle($request);
}

/**
* Returns new instance with middleware handlers replaced.
* Last specified handler will be executed first.
*
* @param array $middlewareDefinitions Each array element is a name of PSR-15 middleware, a callable with
* `function(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface` signature or
* a handler action (an array of [handlerClass, handlerMethod]). For handler action and callable typed parameters
* are automatically injected using dependency injection container passed to the route.
* Current request and handler could be obtained by type-hinting for {@see ServerRequestInterface}
* and {@see RequestHandlerInterface}.
*
* @return self
*/
public function withMiddlewares(array $middlewareDefinitions): self
{
$clone = clone $this;
Expand Down
14 changes: 12 additions & 2 deletions src/MiddlewareFactory.php
Expand Up @@ -27,7 +27,12 @@ public function create($middlewareDefinition): MiddlewareInterface
}

/**
* @param array|callable|string $middlewareDefinition
* @param array|callable|string $middlewareDefinition A name of PSR-15 middleware, a callable with
* `function(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface` signature or
* a handler action (an array of [handlerClass, handlerMethod]). For handler action and callable typed parameters
* are automatically injected using dependency injection container passed to the route.
* Current request and handler could be obtained by type-hinting for {@see ServerRequestInterface}
* and {@see RequestHandlerInterface}.
*
* @return MiddlewareInterface
*/
Expand Down Expand Up @@ -85,7 +90,12 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface
}

/**
* @param array|callable|string $middlewareDefinition
* @param array|callable|string $middlewareDefinition A name of PSR-15 middleware, a callable with
* `function(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface` signature or
* a handler action (an array of [handlerClass, handlerMethod]). For handler action and callable typed parameters
* are automatically injected using dependency injection container passed to the route.
* Current request and handler could be obtained by type-hinting for {@see ServerRequestInterface}
* and {@see RequestHandlerInterface}.
*/
private function validateMiddleware($middlewareDefinition): void
{
Expand Down
9 changes: 9 additions & 0 deletions src/MiddlewareFactoryInterface.php
Expand Up @@ -8,5 +8,14 @@

interface MiddlewareFactoryInterface
{
/**
* @param array|callable|string $middlewareDefinition A name of PSR-15 middleware, a callable with
* `function(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface` signature or
* a handler action (an array of [handlerClass, handlerMethod]). For handler action and callable typed parameters
* are automatically injected using dependency injection container passed to the route.
* Current request and handler could be obtained by type-hinting for {@see ServerRequestInterface}
* and {@see RequestHandlerInterface}.
* @return MiddlewareInterface
*/
public function create($middlewareDefinition): MiddlewareInterface;
}

0 comments on commit 63acb32

Please sign in to comment.