From ce03a651361095a982131f1a320b2b723601f1b7 Mon Sep 17 00:00:00 2001 From: webimpress Date: Fri, 10 Feb 2017 13:34:16 +0000 Subject: [PATCH] CS fixes - fixed indents - parenthesis on instantiating a new class - fixed PHPDocs - added type hinting --- src/Application.php | 2 +- src/IsCallableInteropMiddlewareTrait.php | 2 +- test/Application/ConfigInjectionTest.php | 12 ++--- test/Container/ApplicationFactoryTest.php | 44 ++++++++++--------- .../ErrorResponseGeneratorFactoryTest.php | 10 +++-- test/Router/IntegrationTest.php | 22 +++++----- 6 files changed, 49 insertions(+), 43 deletions(-) diff --git a/src/Application.php b/src/Application.php index c9f1b736..e41a50aa 100644 --- a/src/Application.php +++ b/src/Application.php @@ -123,7 +123,7 @@ public function __construct( * @throws Exception\BadMethodCallException if the $method is not in $httpRouteMethods. * @throws Exception\BadMethodCallException if receiving more or less than 2 arguments. */ - public function __call($method, $args) + public function __call($method, array $args) { if (! in_array(strtoupper($method), $this->httpRouteMethods, true)) { throw new Exception\BadMethodCallException('Unsupported method'); diff --git a/src/IsCallableInteropMiddlewareTrait.php b/src/IsCallableInteropMiddlewareTrait.php index 89fb1cad..1d0c4bca 100644 --- a/src/IsCallableInteropMiddlewareTrait.php +++ b/src/IsCallableInteropMiddlewareTrait.php @@ -16,7 +16,7 @@ trait IsCallableInteropMiddlewareTrait /** * Is callable middleware interop middleware? * - * @param callable $middleware + * @param mixed $middleware * @return bool */ private function isCallableInteropMiddleware($middleware) diff --git a/test/Application/ConfigInjectionTest.php b/test/Application/ConfigInjectionTest.php index 9a0fd896..f522b365 100644 --- a/test/Application/ConfigInjectionTest.php +++ b/test/Application/ConfigInjectionTest.php @@ -99,19 +99,19 @@ public static function assertPipelineContainsInstanceOf($class, $pipeline, $mess public function callableMiddlewares() { return [ - ['HelloWorld'], - [ + ['HelloWorld'], + [ function () { }, - ], - [[InvokableMiddleware::class, 'staticallyCallableMiddleware']], + ], + [[InvokableMiddleware::class, 'staticallyCallableMiddleware']], ]; } /** * @dataProvider callableMiddlewares * - * @param callable $middleware + * @param callable|array|string $middleware */ public function testInjectRoutesFromConfigSetsUpRoutesFromConfig($middleware) { @@ -519,7 +519,7 @@ public function testInjectPipelineFromConfigRaisesExceptionForSpecsOmittingMiddl 'middleware_pipeline' => [ [ 'this' => 'will not work', - ] + ], ], ]; $app = $this->createApplication(); diff --git a/test/Container/ApplicationFactoryTest.php b/test/Container/ApplicationFactoryTest.php index 801c974f..008cb5b3 100644 --- a/test/Container/ApplicationFactoryTest.php +++ b/test/Container/ApplicationFactoryTest.php @@ -124,19 +124,19 @@ public function testFactoryWillPullAllReplaceableDependenciesFromContainerWhenPr public function callableMiddlewares() { return [ - ['HelloWorld'], - [ + ['HelloWorld'], + [ function () { - } - ], - [[InvokableMiddleware::class, 'staticallyCallableMiddleware']], + }, + ], + [[InvokableMiddleware::class, 'staticallyCallableMiddleware']], ]; } /** * @dataProvider callableMiddlewares * - * @param callable $middleware + * @param callable|array|string $middleware */ public function testFactorySetsUpRoutesFromConfig($middleware) { @@ -227,11 +227,11 @@ public function testCanSpecifyRouteOptionsViaConfiguration() { $expected = [ 'values' => [ - 'foo' => 'bar' + 'foo' => 'bar', ], 'tokens' => [ - 'bar' => 'foo' - ] + 'bar' => 'foo', + ], ]; $config = [ 'routes' => [ @@ -240,7 +240,7 @@ public function testCanSpecifyRouteOptionsViaConfiguration() 'middleware' => 'HelloWorld', 'name' => 'home', 'allowed_methods' => ['GET'], - 'options' => $expected + 'options' => $expected, ], ], ]; @@ -314,11 +314,13 @@ public function testWillCreatePipelineBasedOnMiddlewareConfiguration() ['path' => '/dynamic-path', 'middleware' => 'DynamicPath'], ['middleware' => $noPath], ['middleware' => 'Goodbye'], - ['middleware' => [ - $pipelineFirst, - 'Hello', - $pipelineLast, - ]], + [ + 'middleware' => [ + $pipelineFirst, + 'Hello', + $pipelineLast, + ], + ], ]; $config = ['middleware_pipeline' => $pipeline]; @@ -453,11 +455,13 @@ public function testWillNotInjectConfiguredRoutesOrPipelineIfProgrammaticPipelin ['path' => '/dynamic-path', 'middleware' => 'DynamicPath'], ['middleware' => $noPath], ['middleware' => 'Goodbye'], - ['middleware' => [ - $pipelineFirst, - 'Hello', - $pipelineLast, - ]], + [ + 'middleware' => [ + $pipelineFirst, + 'Hello', + $pipelineLast, + ], + ], ], 'routes' => [ [ diff --git a/test/Container/ErrorResponseGeneratorFactoryTest.php b/test/Container/ErrorResponseGeneratorFactoryTest.php index 3009ae42..d1b291f1 100644 --- a/test/Container/ErrorResponseGeneratorFactoryTest.php +++ b/test/Container/ErrorResponseGeneratorFactoryTest.php @@ -73,11 +73,13 @@ public function testUsesConfiguredTemplateRenderToSetGeneratorRenderer() public function testUsesTemplateConfigurationToSetTemplate() { $this->container->has('config')->willReturn(true); - $this->container->get('config')->willReturn(['zend-expressive' => [ - 'error_handler' => [ - 'template_error' => 'error::custom', + $this->container->get('config')->willReturn([ + 'zend-expressive' => [ + 'error_handler' => [ + 'template_error' => 'error::custom', + ], ], - ]]); + ]); $this->container->has(TemplateRendererInterface::class)->willReturn(false); $factory = new ErrorResponseGeneratorFactory(); diff --git a/test/Router/IntegrationTest.php b/test/Router/IntegrationTest.php index 54c5e15e..2ecd2ae1 100644 --- a/test/Router/IntegrationTest.php +++ b/test/Router/IntegrationTest.php @@ -59,9 +59,9 @@ public function getApplication() public function routerAdapters() { return [ - 'aura' => [AuraRouter::class], - 'fast-route' => [FastRouteRouter::class], - 'zf2' => [ZendRouter::class], + 'aura' => [AuraRouter::class], + 'fast-route' => [FastRouteRouter::class], + 'zf2' => [ZendRouter::class], ]; } @@ -76,7 +76,7 @@ public function routerAdapters() */ private function createApplicationWithGetPost($adapter, $getName = null, $postName = null) { - $app = new Application(new $adapter); + $app = new Application(new $adapter()); $app->pipeRoutingMiddleware(); $app->get('/foo', function ($req, $res, $next) { @@ -104,7 +104,7 @@ private function createApplicationWithGetPost($adapter, $getName = null, $postNa */ private function createApplicationWithRouteGetPost($adapter, $getName = null, $postName = null) { - $app = new Application(new $adapter); + $app = new Application(new $adapter()); $app->pipeRoutingMiddleware(); $app->route('/foo', function ($req, $res, $next) { @@ -262,7 +262,7 @@ public function testRoutingWithSamePathWithRouteWithName($adapter) */ public function testRoutingWithSamePathWithRouteWithMultipleMethods($adapter) { - $app = new Application(new $adapter); + $app = new Application(new $adapter()); $app->pipeRoutingMiddleware(); $app->pipeDispatchMiddleware(); @@ -322,7 +322,7 @@ public function routerAdaptersForHttpMethods() */ public function testMatchWithAllHttpMethods($adapter, $method) { - $app = new Application(new $adapter); + $app = new Application(new $adapter()); $app->pipeRoutingMiddleware(); $app->pipeDispatchMiddleware(); @@ -382,7 +382,7 @@ public function notAllowedMethod() */ public function testAllowedMethodsWhenOnlyPutMethodSet($adapter, $method) { - $app = new Application(new $adapter); + $app = new Application(new $adapter()); $app->pipeRoutingMiddleware(); $app->pipe(new Middleware\ImplicitHeadMiddleware()); $app->pipe(new Middleware\ImplicitOptionsMiddleware()); @@ -414,7 +414,7 @@ public function testAllowedMethodsWhenOnlyPutMethodSet($adapter, $method) */ public function testAllowedMethodsWhenNoHttpMethodsSet($adapter, $method) { - $app = new Application(new $adapter); + $app = new Application(new $adapter()); $app->pipeRoutingMiddleware(); $app->pipe(new Middleware\ImplicitHeadMiddleware()); $app->pipe(new Middleware\ImplicitOptionsMiddleware()); @@ -446,7 +446,7 @@ public function testAllowedMethodsWhenNoHttpMethodsSet($adapter, $method) */ public function testNotAllowedMethodWhenNoHttpMethodsSet($adapter, $method) { - $app = new Application(new $adapter); + $app = new Application(new $adapter()); $app->pipeRoutingMiddleware(); $app->pipeDispatchMiddleware(); @@ -476,7 +476,7 @@ public function testNotAllowedMethodWhenNoHttpMethodsSet($adapter, $method) */ public function testWithOnlyRootPathRouteDefinedRoutingToSubPathsShouldDelegate($adapter) { - $app = new Application(new $adapter); + $app = new Application(new $adapter()); $app->pipeRoutingMiddleware(); $app->route('/', function ($req, $res, $next) {