Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit eb22db4

Browse files
committed
Add missing types
1 parent d6f08f2 commit eb22db4

20 files changed

+54
-52
lines changed

src/AppFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class AppFactory
5050
public static function create(
5151
ContainerInterface $container = null,
5252
Router\RouterInterface $router = null
53-
) {
53+
): Application {
5454
if (! $container && ! class_exists(ServiceManager::class)) {
5555
throw new Exception\MissingDependencyException(sprintf(
5656
'%s requires a container, but none was provided and %s is not installed',

src/Application.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function __construct(
114114
* @param null|string $name The name of the route.
115115
* @return Router\Route
116116
*/
117-
public function get($path, $middleware, $name = null)
117+
public function get($path, $middleware, string $name = null): Router\Route
118118
{
119119
return $this->route($path, $middleware, ['GET'], $name);
120120
}
@@ -125,7 +125,7 @@ public function get($path, $middleware, $name = null)
125125
* @param null|string $name The name of the route.
126126
* @return Router\Route
127127
*/
128-
public function post($path, $middleware, $name = null)
128+
public function post($path, $middleware, $name = null): Router\Route
129129
{
130130
return $this->route($path, $middleware, ['POST'], $name);
131131
}
@@ -136,7 +136,7 @@ public function post($path, $middleware, $name = null)
136136
* @param null|string $name The name of the route.
137137
* @return Router\Route
138138
*/
139-
public function put($path, $middleware, $name = null)
139+
public function put($path, $middleware, string $name = null): Router\Route
140140
{
141141
return $this->route($path, $middleware, ['PUT'], $name);
142142
}
@@ -147,7 +147,7 @@ public function put($path, $middleware, $name = null)
147147
* @param null|string $name The name of the route.
148148
* @return Router\Route
149149
*/
150-
public function patch($path, $middleware, $name = null)
150+
public function patch($path, $middleware, string $name = null): Router\Route
151151
{
152152
return $this->route($path, $middleware, ['PATCH'], $name);
153153
}
@@ -158,7 +158,7 @@ public function patch($path, $middleware, $name = null)
158158
* @param null|string $name The name of the route.
159159
* @return Router\Route
160160
*/
161-
public function delete($path, $middleware, $name = null)
161+
public function delete($path, $middleware, string $name = null): Router\Route
162162
{
163163
return $this->route($path, $middleware, ['DELETE'], $name);
164164
}
@@ -169,7 +169,7 @@ public function delete($path, $middleware, $name = null)
169169
* @param null|string $name The name of the route.
170170
* @return Router\Route
171171
*/
172-
public function any($path, $middleware, $name = null)
172+
public function any($path, $middleware, string $name = null): Router\Route
173173
{
174174
return $this->route($path, $middleware, null, $name);
175175
}
@@ -257,7 +257,7 @@ public function pipe($path, $middleware = null) : parent
257257
*
258258
* @return void
259259
*/
260-
public function pipeRoutingMiddleware()
260+
public function pipeRoutingMiddleware(): void
261261
{
262262
if ($this->routeMiddlewareIsRegistered) {
263263
return;
@@ -270,7 +270,7 @@ public function pipeRoutingMiddleware()
270270
*
271271
* @return void
272272
*/
273-
public function pipeDispatchMiddleware()
273+
public function pipeDispatchMiddleware(): void
274274
{
275275
if ($this->dispatchMiddlewareIsRegistered) {
276276
return;
@@ -317,7 +317,7 @@ public function route(string $path, $middleware, array $methods = null, string $
317317
*
318318
* @return Router\Route[]
319319
*/
320-
public function getRoutes()
320+
public function getRoutes(): iterable
321321
{
322322
return $this->routes;
323323
}
@@ -339,7 +339,7 @@ public function getRoutes()
339339
* @param null|ResponseInterface $response
340340
* @return void
341341
*/
342-
public function run(ServerRequestInterface $request = null, ResponseInterface $response = null)
342+
public function run(ServerRequestInterface $request = null, ResponseInterface $response = null): void
343343
{
344344
try {
345345
$request = $request ?: ServerRequestFactory::fromGlobals();
@@ -367,7 +367,7 @@ public function run(ServerRequestInterface $request = null, ResponseInterface $r
367367
* @return ContainerInterface
368368
* @throws Exception\ContainerNotRegisteredException
369369
*/
370-
public function getContainer()
370+
public function getContainer(): ContainerInterface
371371
{
372372
if (null === $this->container) {
373373
throw new Exception\ContainerNotRegisteredException();
@@ -387,7 +387,7 @@ public function getContainer()
387387
*
388388
* @return RequestHandlerInterface
389389
*/
390-
public function getDefaultDelegate()
390+
public function getDefaultDelegate(): RequestHandlerInterface
391391
{
392392
if ($this->defaultDelegate) {
393393
return $this->defaultDelegate;
@@ -416,7 +416,7 @@ public function getDefaultDelegate()
416416
*
417417
* @return EmitterInterface
418418
*/
419-
public function getEmitter()
419+
public function getEmitter(): EmitterInterface
420420
{
421421
if (! $this->emitter) {
422422
$this->emitter = new Emitter\EmitterStack();
@@ -436,7 +436,7 @@ public function getEmitter()
436436
* @param null|array $methods
437437
* @throws Exception\DuplicateRouteException on duplicate route detection.
438438
*/
439-
private function checkForDuplicateRoute($path, $methods = null)
439+
private function checkForDuplicateRoute(string $path, array $methods = null): void
440440
{
441441
if (null === $methods) {
442442
$methods = Router\Route::HTTP_METHOD_ANY;
@@ -467,7 +467,7 @@ private function checkForDuplicateRoute($path, $methods = null)
467467
* @param Throwable $exception
468468
* @return void
469469
*/
470-
private function emitMarshalServerRequestException(Throwable $exception)
470+
private function emitMarshalServerRequestException(Throwable $exception): void
471471
{
472472
if ($this->container && $this->container->has(Middleware\ErrorResponseGenerator::class)) {
473473
$generator = $this->container->get(Middleware\ErrorResponseGenerator::class);

src/ApplicationConfigInjectionTrait.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ trait ApplicationConfigInjectionTrait
6969
* from the composed container.
7070
* @return void
7171
*/
72-
public function injectPipelineFromConfig(array $config = null)
72+
public function injectPipelineFromConfig(array $config = null): void
7373
{
7474
if (null === $config) {
7575
$config = $this->container->has('config') ? $this->container->get('config') : [];
@@ -139,7 +139,7 @@ public function injectPipelineFromConfig(array $config = null)
139139
* @return void
140140
* @throws Exception\InvalidArgumentException
141141
*/
142-
public function injectRoutesFromConfig(array $config = null)
142+
public function injectRoutesFromConfig(array $config = null): void
143143
{
144144
if (null === $config) {
145145
$config = $this->container->has('config') ? $this->container->get('config') : [];
@@ -205,7 +205,7 @@ public function injectRoutesFromConfig(array $config = null)
205205
* @return callable
206206
* @throws Exception\InvalidArgumentException
207207
*/
208-
private function createCollectionMapper()
208+
private function createCollectionMapper(): callable
209209
{
210210
$appMiddlewares = [
211211
Application::ROUTING_MIDDLEWARE,

src/Container/ApplicationFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ApplicationFactory
5858
* @param ContainerInterface $container
5959
* @return Application
6060
*/
61-
public function __invoke(ContainerInterface $container)
61+
public function __invoke(ContainerInterface $container): Application
6262
{
6363
$config = $container->has('config') ? $container->get('config') : [];
6464
$config = $config instanceof ArrayObject ? $config->getArrayCopy() : $config;
@@ -91,7 +91,7 @@ public function __invoke(ContainerInterface $container)
9191
* @param array $config
9292
* @return void
9393
*/
94-
private function injectRoutesAndPipeline(Application $app, array $config)
94+
private function injectRoutesAndPipeline(Application $app, array $config): void
9595
{
9696
$app->injectRoutesFromConfig($config);
9797
$app->injectPipelineFromConfig($config);

src/Container/ErrorHandlerFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ErrorHandlerFactory
2020
* @param ContainerInterface $container
2121
* @return ErrorHandler
2222
*/
23-
public function __invoke(ContainerInterface $container)
23+
public function __invoke(ContainerInterface $container): ErrorHandler
2424
{
2525
$generator = $container->has(ErrorResponseGenerator::class)
2626
? $container->get(ErrorResponseGenerator::class)

src/Container/ErrorResponseGeneratorFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ErrorResponseGeneratorFactory
1919
* @param ContainerInterface $container
2020
* @return ErrorResponseGenerator
2121
*/
22-
public function __invoke(ContainerInterface $container)
22+
public function __invoke(ContainerInterface $container): ErrorResponseGenerator
2323
{
2424
$config = $container->has('config') ? $container->get('config') : [];
2525

src/Container/NotFoundDelegateFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class NotFoundDelegateFactory
2020
* @param ContainerInterface $container
2121
* @return NotFoundDelegate
2222
*/
23-
public function __invoke(ContainerInterface $container)
23+
public function __invoke(ContainerInterface $container): NotFoundDelegate
2424
{
2525
$config = $container->has('config') ? $container->get('config') : [];
2626
$renderer = $container->has(TemplateRendererInterface::class)

src/Container/NotFoundHandlerFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class NotFoundHandlerFactory
1919
* @param ContainerInterface $container
2020
* @return NotFoundHandler
2121
*/
22-
public function __invoke(ContainerInterface $container)
22+
public function __invoke(ContainerInterface $container): NotFoundHandler
2323
{
2424
return new NotFoundHandler($container->get(NotFoundDelegate::class));
2525
}

src/Container/WhoopsErrorResponseGeneratorFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class WhoopsErrorResponseGeneratorFactory
1818
* @param ContainerInterface $container
1919
* @return WhoopsErrorResponseGenerator
2020
*/
21-
public function __invoke(ContainerInterface $container)
21+
public function __invoke(ContainerInterface $container): WhoopsErrorResponseGenerator
2222
{
2323
return new WhoopsErrorResponseGenerator(
2424
$container->get('Zend\Expressive\Whoops')

src/Container/WhoopsFactory.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ class WhoopsFactory
4848
* @param ContainerInterface $container
4949
* @return Whoops
5050
*/
51-
public function __invoke(ContainerInterface $container)
51+
public function __invoke(ContainerInterface $container): Whoops
5252
{
5353
$config = $container->has('config') ? $container->get('config') : [];
5454
$config = $config['whoops'] ?? [];
@@ -69,7 +69,7 @@ public function __invoke(ContainerInterface $container)
6969
* @param array|\ArrayAccess $config
7070
* @return void
7171
*/
72-
private function registerJsonHandler(Whoops $whoops, $config)
72+
private function registerJsonHandler(Whoops $whoops, $config): void
7373
{
7474
if (empty($config['json_exceptions']['display'])) {
7575
return;

0 commit comments

Comments
 (0)