From 89726b149a2a67c2132701c40ab1e1b841a7edc9 Mon Sep 17 00:00:00 2001 From: Maciej Iwanowski Date: Tue, 14 Apr 2015 20:17:26 +0200 Subject: [PATCH 1/4] bunch of PSR-2 formatting fixes --- src/Console/Commands/ServeCommand.php | 4 +-- src/Foundation/Composer.php | 7 ++--- src/Providers/CacheServiceProvider.php | 7 ++--- tests/FullApplicationTest.php | 39 +++++++++++++++----------- tests/fixtures/TestController.php | 6 ++-- 5 files changed, 35 insertions(+), 28 deletions(-) diff --git a/src/Console/Commands/ServeCommand.php b/src/Console/Commands/ServeCommand.php index 13dc0411..eee1b852 100644 --- a/src/Console/Commands/ServeCommand.php +++ b/src/Console/Commands/ServeCommand.php @@ -3,7 +3,8 @@ use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; -class ServeCommand extends Command { +class ServeCommand extends Command +{ /** * The console command name. @@ -52,5 +53,4 @@ protected function getOptions() array('port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000), ); } - } diff --git a/src/Foundation/Composer.php b/src/Foundation/Composer.php index 0868487a..9c49bd04 100644 --- a/src/Foundation/Composer.php +++ b/src/Foundation/Composer.php @@ -3,7 +3,8 @@ use Illuminate\Filesystem\Filesystem; use Symfony\Component\Process\Process; -class Composer { +class Composer +{ /** * The filesystem instance. @@ -64,8 +65,7 @@ public function dumpOptimized() */ protected function findComposer() { - if ($this->files->exists($this->workingPath.'/composer.phar')) - { + if ($this->files->exists($this->workingPath.'/composer.phar')) { return '"'.PHP_BINARY.'" composer.phar'; } @@ -94,5 +94,4 @@ public function setWorkingPath($path) return $this; } - } diff --git a/src/Providers/CacheServiceProvider.php b/src/Providers/CacheServiceProvider.php index d6e56ad1..da9ad7bf 100644 --- a/src/Providers/CacheServiceProvider.php +++ b/src/Providers/CacheServiceProvider.php @@ -3,7 +3,8 @@ use Illuminate\Cache\Console\ClearCommand; use Illuminate\Cache\CacheServiceProvider as BaseProvider; -class CacheServiceProvider extends BaseProvider { +class CacheServiceProvider extends BaseProvider +{ /** * Register the cache related console commands. @@ -12,12 +13,10 @@ class CacheServiceProvider extends BaseProvider { */ public function registerCommands() { - $this->app->singleton('command.cache.clear', function($app) - { + $this->app->singleton('command.cache.clear', function ($app) { return new ClearCommand($app['cache']); }); $this->commands('command.cache.clear'); } - } diff --git a/tests/FullApplicationTest.php b/tests/FullApplicationTest.php index 6d3bb2d1..b83a697e 100644 --- a/tests/FullApplicationTest.php +++ b/tests/FullApplicationTest.php @@ -54,7 +54,7 @@ public function testRouteMiddleware() return response('Hello World'); }); - $app->get('/foo', ['middleware' => 'foo', function() { + $app->get('/foo', ['middleware' => 'foo', function () { return response('Hello World'); }]); @@ -74,13 +74,13 @@ public function testGroupRouteMiddleware() $app->routeMiddleware(['foo' => 'LumenTestMiddleware']); - $app->group(['middleware' => 'foo'], function($app) { + $app->group(['middleware' => 'foo'], function ($app) { $app->get('/', function () { return response('Hello World'); }); }); - $app->get('/foo', function() { + $app->get('/foo', function () { return response('Hello World'); }); @@ -145,7 +145,7 @@ public function testNamespacedControllerResponse() require_once __DIR__.'/fixtures/TestController.php'; - $app->group(['namespace' => 'Lumen\Tests'], function($app) { + $app->group(['namespace' => 'Lumen\Tests'], function ($app) { $app->get('/', 'TestController@action'); }); @@ -162,11 +162,11 @@ public function testGeneratingUrls() $app->instance('request', Request::create('http://lumen.com', 'GET')); unset($app->availableBindings['request']); - $app->get('/foo-bar', ['as' => 'foo', function() { + $app->get('/foo-bar', ['as' => 'foo', function () { // }]); - $app->get('/foo-bar/{baz}/{boom}', ['as' => 'bar', function() { + $app->get('/foo-bar/{baz}/{boom}', ['as' => 'bar', function () { // }]); @@ -182,15 +182,15 @@ public function testGeneratingUrlsForRegexParameters() $app->instance('request', Request::create('http://lumen.com', 'GET')); unset($app->availableBindings['request']); - $app->get('/foo-bar', ['as' => 'foo', function() { + $app->get('/foo-bar', ['as' => 'foo', function () { // }]); - $app->get('/foo-bar/{baz:[0-9]+}/{boom}', ['as' => 'bar', function() { + $app->get('/foo-bar/{baz:[0-9]+}/{boom}', ['as' => 'bar', function () { // }]); - $app->get('/foo-bar/{baz:[0-9]+}/{boom:[0-9]+}', ['as' => 'baz', function() { + $app->get('/foo-bar/{baz:[0-9]+}/{boom:[0-9]+}', ['as' => 'baz', function () { // }]); @@ -201,20 +201,27 @@ public function testGeneratingUrlsForRegexParameters() } } -class LumenTestService {} +class LumenTestService +{ +} -class LumenTestMiddleware { - public function handle($request, $next) { - return response('Middleware'); +class LumenTestMiddleware +{ + public function handle($request, $next) + { + return response('Middleware'); } } -class LumenTestController { +class LumenTestController +{ public $service; - public function __construct(LumenTestService $service) { + public function __construct(LumenTestService $service) + { $this->service = $service; } - public function action() { + public function action() + { return response(__CLASS__); } } diff --git a/tests/fixtures/TestController.php b/tests/fixtures/TestController.php index fdca2402..aae90236 100644 --- a/tests/fixtures/TestController.php +++ b/tests/fixtures/TestController.php @@ -1,7 +1,9 @@ Date: Tue, 14 Apr 2015 20:29:27 +0200 Subject: [PATCH 2/4] number of manually applied fixes --- src/Application.php | 44 +++++++++++----------- src/Console/Commands/RouteCacheCommand.php | 4 +- src/Console/Commands/ServeCommand.php | 8 +++- src/Console/Kernel.php | 4 +- src/Routing/UrlGenerator.php | 4 +- src/Routing/ValidatesRequests.php | 9 +++-- src/Testing/AssertionsTrait.php | 6 ++- 7 files changed, 44 insertions(+), 35 deletions(-) diff --git a/src/Application.php b/src/Application.php index 2064f418..d124bd12 100644 --- a/src/Application.php +++ b/src/Application.php @@ -370,7 +370,11 @@ protected function registerAuthBindings() }); $this->singleton('auth.password', function () { - return $this->loadComponent('auth', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'auth.password'); + return $this->loadComponent( + 'auth', + 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', + 'auth.password' + ); }); } @@ -445,9 +449,11 @@ protected function registerDatabaseBindings() { $this->singleton('db', function () { return $this->loadComponent( - 'database', [ + 'database', + [ 'Illuminate\Database\DatabaseServiceProvider', - 'Illuminate\Pagination\PaginationServiceProvider'], + 'Illuminate\Pagination\PaginationServiceProvider' + ], 'db' ); }); @@ -488,7 +494,8 @@ protected function registerErrorBindings() { if (! $this->bound('Illuminate\Contracts\Debug\ExceptionHandler')) { $this->singleton( - 'Illuminate\Contracts\Debug\ExceptionHandler', 'Laravel\Lumen\Exceptions\Handler' + 'Illuminate\Contracts\Debug\ExceptionHandler', + 'Laravel\Lumen\Exceptions\Handler' ); } } @@ -1031,7 +1038,8 @@ protected function callTerminableMiddleware($response) if ($instance instanceof TerminableMiddleware) { $instance->terminate( - $this->make('request'), $response + $this->make('request'), + $response ); } } @@ -1189,7 +1197,11 @@ protected function callControllerAction($routeInfo) return $this->callLumenController($instance, $method, $routeInfo); } else { return $this->callControllerCallable( - [$instance, $method], array_values($routeInfo[2]) + [ + $instance, + $method + ], + array_values($routeInfo[2]) ); } } @@ -1204,18 +1216,12 @@ protected function callControllerAction($routeInfo) */ protected function callLumenController($instance, $method, $routeInfo) { - $middleware = $instance->getMiddlewareForMethod( - $this->make('request'), $method - ); + $middleware = $instance->getMiddlewareForMethod($this->make('request'), $method); if (count($middleware) > 0) { - return $this->callLumenControllerWithMiddleware( - $instance, $method, $routeInfo, $middleware - ); + return $this->callLumenControllerWithMiddleware($instance, $method, $routeInfo, $middleware); } else { - return $this->callControllerCallable( - [$instance, $method], array_values($routeInfo[2]) - ); + return $this->callControllerCallable([$instance, $method], array_values($routeInfo[2])); } } @@ -1233,9 +1239,7 @@ protected function callLumenControllerWithMiddleware($instance, $method, $routeI $middleware = $this->gatherMiddlewareClassNames($middleware); return $this->sendThroughPipeline($middleware, function () use ($instance, $method, $routeInfo) { - return $this->callControllerCallable( - [$instance, $method], array_values($routeInfo[2]) - ); + return $this->callControllerCallable([$instance, $method], array_values($routeInfo[2])); }); } @@ -1249,9 +1253,7 @@ protected function callLumenControllerWithMiddleware($instance, $method, $routeI protected function callControllerCallable(array $callable, array $parameters) { try { - return $this->prepareResponse( - $this->call($callable, $parameters) - ); + return $this->prepareResponse($this->call($callable, $parameters)); } catch (HttpResponseException $e) { return $e->getResponse(); } diff --git a/src/Console/Commands/RouteCacheCommand.php b/src/Console/Commands/RouteCacheCommand.php index 1897d045..66d19208 100644 --- a/src/Console/Commands/RouteCacheCommand.php +++ b/src/Console/Commands/RouteCacheCommand.php @@ -35,9 +35,7 @@ public function fire() return $this->error("Your application doesn't have any routes."); } - file_put_contents( - $this->laravel->getCachedRoutesPath(), $this->buildRouteCacheFile($routes) - ); + file_put_contents($this->laravel->getCachedRoutesPath(), $this->buildRouteCacheFile($routes)); $this->info('Routes cached successfully!'); } diff --git a/src/Console/Commands/ServeCommand.php b/src/Console/Commands/ServeCommand.php index eee1b852..269a02ad 100644 --- a/src/Console/Commands/ServeCommand.php +++ b/src/Console/Commands/ServeCommand.php @@ -48,7 +48,13 @@ public function fire() protected function getOptions() { return array( - array('host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', 'localhost'), + array( + 'host', + null, + InputOption::VALUE_OPTIONAL, + 'The host address to serve the application on.', + 'localhost' + ), array('port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000), ); diff --git a/src/Console/Kernel.php b/src/Console/Kernel.php index 973af457..8950c1f4 100644 --- a/src/Console/Kernel.php +++ b/src/Console/Kernel.php @@ -55,9 +55,7 @@ public function __construct(Application $app) */ protected function defineConsoleSchedule() { - $this->app->instance( - 'Illuminate\Console\Scheduling\Schedule', $schedule = new Schedule - ); + $this->app->instance('Illuminate\Console\Scheduling\Schedule', $schedule = new Schedule); $this->schedule($schedule); } diff --git a/src/Routing/UrlGenerator.php b/src/Routing/UrlGenerator.php index 472c8d8f..69f2a86d 100644 --- a/src/Routing/UrlGenerator.php +++ b/src/Routing/UrlGenerator.php @@ -59,9 +59,7 @@ public function to($path, $extra = array(), $secure = null) $extra = $this->formatParametersForUrl($extra); - $tail = implode('/', array_map( - 'rawurlencode', (array) $extra) - ); + $tail = implode('/', array_map('rawurlencode', (array)$extra)); // Once we have the scheme we will compile the "tail" by collapsing the values // into a single string delimited by slashes. This just makes it convenient diff --git a/src/Routing/ValidatesRequests.php b/src/Routing/ValidatesRequests.php index 697ad8e7..15053506 100644 --- a/src/Routing/ValidatesRequests.php +++ b/src/Routing/ValidatesRequests.php @@ -34,9 +34,12 @@ public function validate(Request $request, array $rules, array $messages = array */ protected function throwValidationException(Request $request, $validator) { - throw new HttpResponseException($this->buildFailedValidationResponse( - $request, $this->formatValidationErrors($validator) - )); + throw new HttpResponseException( + $this->buildFailedValidationResponse( + $request, + $this->formatValidationErrors($validator) + ) + ); } /** diff --git a/src/Testing/AssertionsTrait.php b/src/Testing/AssertionsTrait.php index 31d9ce43..f5a9344a 100644 --- a/src/Testing/AssertionsTrait.php +++ b/src/Testing/AssertionsTrait.php @@ -28,7 +28,11 @@ public function assertResponseStatus($code) { $actual = $this->response->getStatusCode(); - return PHPUnit::assertEquals($code, $this->response->getStatusCode(), "Expected status code {$code}, got {$actual}."); + return PHPUnit::assertEquals( + $code, + $this->response->getStatusCode(), + "Expected status code {$code}, got {$actual}." + ); } /** From 4c829e38a52aebbdfe78142339535e90ec3a6228 Mon Sep 17 00:00:00 2001 From: Maciej Iwanowski Date: Tue, 14 Apr 2015 20:34:25 +0200 Subject: [PATCH 3/4] function signature PSR-2 fixes --- src/Testing/ApplicationTrait.php | 23 +++++++++++++++++++---- src/helpers.php | 11 +++++++++-- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/src/Testing/ApplicationTrait.php b/src/Testing/ApplicationTrait.php index 2a3a28a3..f52697e6 100644 --- a/src/Testing/ApplicationTrait.php +++ b/src/Testing/ApplicationTrait.php @@ -70,8 +70,15 @@ public function call($method, $uri, $parameters = [], $cookies = [], $files = [] * @param string $content * @return \Illuminate\Http\Response */ - public function callSecure($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null) - { + public function callSecure( + $method, + $uri, + $parameters = [], + $cookies = [], + $files = [], + $server = [], + $content = null + ) { $uri = 'https://localhost/'.ltrim($uri, '/'); return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content); @@ -90,8 +97,16 @@ public function callSecure($method, $uri, $parameters = [], $cookies = [], $file * @param string $content * @return \Illuminate\Http\Response */ - public function route($method, $name, $routeParameters = [], $parameters = [], $cookies = [], $files = [], $server = [], $content = null) - { + public function route( + $method, + $name, + $routeParameters = [], + $parameters = [], + $cookies = [], + $files = [], + $server = [], + $content = null + ) { $uri = $this->app['url']->route($name, $routeParameters); return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content); diff --git a/src/helpers.php b/src/helpers.php index 5747474e..985a2fb2 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -103,8 +103,15 @@ function config($key = null, $default = null) * @param bool $httpOnly * @return \Symfony\Component\HttpFoundation\Cookie */ - function cookie($name = null, $value = null, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true) - { + function cookie( + $name = null, + $value = null, + $minutes = 0, + $path = null, + $domain = null, + $secure = false, + $httpOnly = true + ) { $cookie = app('cookie'); if (is_null($name)) { From 7568473e1505073338b4f4ab3ee28f0db5bbb654 Mon Sep 17 00:00:00 2001 From: Maciej Iwanowski Date: Tue, 14 Apr 2015 20:17:26 +0200 Subject: [PATCH 4/4] bunch of PSR-2 formatting fixes number of manually applied fixes function signature PSR-2 fixes --- src/Application.php | 44 +++++++++++----------- src/Console/Commands/RouteCacheCommand.php | 4 +- src/Console/Commands/ServeCommand.php | 12 ++++-- src/Console/Kernel.php | 4 +- src/Foundation/Composer.php | 7 ++-- src/Providers/CacheServiceProvider.php | 7 ++-- src/Routing/UrlGenerator.php | 4 +- src/Routing/ValidatesRequests.php | 9 +++-- src/Testing/ApplicationTrait.php | 23 +++++++++-- src/Testing/AssertionsTrait.php | 6 ++- src/helpers.php | 11 +++++- tests/FullApplicationTest.php | 39 +++++++++++-------- tests/fixtures/TestController.php | 6 ++- 13 files changed, 107 insertions(+), 69 deletions(-) diff --git a/src/Application.php b/src/Application.php index 2064f418..d124bd12 100644 --- a/src/Application.php +++ b/src/Application.php @@ -370,7 +370,11 @@ protected function registerAuthBindings() }); $this->singleton('auth.password', function () { - return $this->loadComponent('auth', 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', 'auth.password'); + return $this->loadComponent( + 'auth', + 'Illuminate\Auth\Passwords\PasswordResetServiceProvider', + 'auth.password' + ); }); } @@ -445,9 +449,11 @@ protected function registerDatabaseBindings() { $this->singleton('db', function () { return $this->loadComponent( - 'database', [ + 'database', + [ 'Illuminate\Database\DatabaseServiceProvider', - 'Illuminate\Pagination\PaginationServiceProvider'], + 'Illuminate\Pagination\PaginationServiceProvider' + ], 'db' ); }); @@ -488,7 +494,8 @@ protected function registerErrorBindings() { if (! $this->bound('Illuminate\Contracts\Debug\ExceptionHandler')) { $this->singleton( - 'Illuminate\Contracts\Debug\ExceptionHandler', 'Laravel\Lumen\Exceptions\Handler' + 'Illuminate\Contracts\Debug\ExceptionHandler', + 'Laravel\Lumen\Exceptions\Handler' ); } } @@ -1031,7 +1038,8 @@ protected function callTerminableMiddleware($response) if ($instance instanceof TerminableMiddleware) { $instance->terminate( - $this->make('request'), $response + $this->make('request'), + $response ); } } @@ -1189,7 +1197,11 @@ protected function callControllerAction($routeInfo) return $this->callLumenController($instance, $method, $routeInfo); } else { return $this->callControllerCallable( - [$instance, $method], array_values($routeInfo[2]) + [ + $instance, + $method + ], + array_values($routeInfo[2]) ); } } @@ -1204,18 +1216,12 @@ protected function callControllerAction($routeInfo) */ protected function callLumenController($instance, $method, $routeInfo) { - $middleware = $instance->getMiddlewareForMethod( - $this->make('request'), $method - ); + $middleware = $instance->getMiddlewareForMethod($this->make('request'), $method); if (count($middleware) > 0) { - return $this->callLumenControllerWithMiddleware( - $instance, $method, $routeInfo, $middleware - ); + return $this->callLumenControllerWithMiddleware($instance, $method, $routeInfo, $middleware); } else { - return $this->callControllerCallable( - [$instance, $method], array_values($routeInfo[2]) - ); + return $this->callControllerCallable([$instance, $method], array_values($routeInfo[2])); } } @@ -1233,9 +1239,7 @@ protected function callLumenControllerWithMiddleware($instance, $method, $routeI $middleware = $this->gatherMiddlewareClassNames($middleware); return $this->sendThroughPipeline($middleware, function () use ($instance, $method, $routeInfo) { - return $this->callControllerCallable( - [$instance, $method], array_values($routeInfo[2]) - ); + return $this->callControllerCallable([$instance, $method], array_values($routeInfo[2])); }); } @@ -1249,9 +1253,7 @@ protected function callLumenControllerWithMiddleware($instance, $method, $routeI protected function callControllerCallable(array $callable, array $parameters) { try { - return $this->prepareResponse( - $this->call($callable, $parameters) - ); + return $this->prepareResponse($this->call($callable, $parameters)); } catch (HttpResponseException $e) { return $e->getResponse(); } diff --git a/src/Console/Commands/RouteCacheCommand.php b/src/Console/Commands/RouteCacheCommand.php index 1897d045..66d19208 100644 --- a/src/Console/Commands/RouteCacheCommand.php +++ b/src/Console/Commands/RouteCacheCommand.php @@ -35,9 +35,7 @@ public function fire() return $this->error("Your application doesn't have any routes."); } - file_put_contents( - $this->laravel->getCachedRoutesPath(), $this->buildRouteCacheFile($routes) - ); + file_put_contents($this->laravel->getCachedRoutesPath(), $this->buildRouteCacheFile($routes)); $this->info('Routes cached successfully!'); } diff --git a/src/Console/Commands/ServeCommand.php b/src/Console/Commands/ServeCommand.php index 13dc0411..269a02ad 100644 --- a/src/Console/Commands/ServeCommand.php +++ b/src/Console/Commands/ServeCommand.php @@ -3,7 +3,8 @@ use Illuminate\Console\Command; use Symfony\Component\Console\Input\InputOption; -class ServeCommand extends Command { +class ServeCommand extends Command +{ /** * The console command name. @@ -47,10 +48,15 @@ public function fire() protected function getOptions() { return array( - array('host', null, InputOption::VALUE_OPTIONAL, 'The host address to serve the application on.', 'localhost'), + array( + 'host', + null, + InputOption::VALUE_OPTIONAL, + 'The host address to serve the application on.', + 'localhost' + ), array('port', null, InputOption::VALUE_OPTIONAL, 'The port to serve the application on.', 8000), ); } - } diff --git a/src/Console/Kernel.php b/src/Console/Kernel.php index 973af457..8950c1f4 100644 --- a/src/Console/Kernel.php +++ b/src/Console/Kernel.php @@ -55,9 +55,7 @@ public function __construct(Application $app) */ protected function defineConsoleSchedule() { - $this->app->instance( - 'Illuminate\Console\Scheduling\Schedule', $schedule = new Schedule - ); + $this->app->instance('Illuminate\Console\Scheduling\Schedule', $schedule = new Schedule); $this->schedule($schedule); } diff --git a/src/Foundation/Composer.php b/src/Foundation/Composer.php index 0868487a..9c49bd04 100644 --- a/src/Foundation/Composer.php +++ b/src/Foundation/Composer.php @@ -3,7 +3,8 @@ use Illuminate\Filesystem\Filesystem; use Symfony\Component\Process\Process; -class Composer { +class Composer +{ /** * The filesystem instance. @@ -64,8 +65,7 @@ public function dumpOptimized() */ protected function findComposer() { - if ($this->files->exists($this->workingPath.'/composer.phar')) - { + if ($this->files->exists($this->workingPath.'/composer.phar')) { return '"'.PHP_BINARY.'" composer.phar'; } @@ -94,5 +94,4 @@ public function setWorkingPath($path) return $this; } - } diff --git a/src/Providers/CacheServiceProvider.php b/src/Providers/CacheServiceProvider.php index d6e56ad1..da9ad7bf 100644 --- a/src/Providers/CacheServiceProvider.php +++ b/src/Providers/CacheServiceProvider.php @@ -3,7 +3,8 @@ use Illuminate\Cache\Console\ClearCommand; use Illuminate\Cache\CacheServiceProvider as BaseProvider; -class CacheServiceProvider extends BaseProvider { +class CacheServiceProvider extends BaseProvider +{ /** * Register the cache related console commands. @@ -12,12 +13,10 @@ class CacheServiceProvider extends BaseProvider { */ public function registerCommands() { - $this->app->singleton('command.cache.clear', function($app) - { + $this->app->singleton('command.cache.clear', function ($app) { return new ClearCommand($app['cache']); }); $this->commands('command.cache.clear'); } - } diff --git a/src/Routing/UrlGenerator.php b/src/Routing/UrlGenerator.php index 472c8d8f..69f2a86d 100644 --- a/src/Routing/UrlGenerator.php +++ b/src/Routing/UrlGenerator.php @@ -59,9 +59,7 @@ public function to($path, $extra = array(), $secure = null) $extra = $this->formatParametersForUrl($extra); - $tail = implode('/', array_map( - 'rawurlencode', (array) $extra) - ); + $tail = implode('/', array_map('rawurlencode', (array)$extra)); // Once we have the scheme we will compile the "tail" by collapsing the values // into a single string delimited by slashes. This just makes it convenient diff --git a/src/Routing/ValidatesRequests.php b/src/Routing/ValidatesRequests.php index 697ad8e7..15053506 100644 --- a/src/Routing/ValidatesRequests.php +++ b/src/Routing/ValidatesRequests.php @@ -34,9 +34,12 @@ public function validate(Request $request, array $rules, array $messages = array */ protected function throwValidationException(Request $request, $validator) { - throw new HttpResponseException($this->buildFailedValidationResponse( - $request, $this->formatValidationErrors($validator) - )); + throw new HttpResponseException( + $this->buildFailedValidationResponse( + $request, + $this->formatValidationErrors($validator) + ) + ); } /** diff --git a/src/Testing/ApplicationTrait.php b/src/Testing/ApplicationTrait.php index 2a3a28a3..f52697e6 100644 --- a/src/Testing/ApplicationTrait.php +++ b/src/Testing/ApplicationTrait.php @@ -70,8 +70,15 @@ public function call($method, $uri, $parameters = [], $cookies = [], $files = [] * @param string $content * @return \Illuminate\Http\Response */ - public function callSecure($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null) - { + public function callSecure( + $method, + $uri, + $parameters = [], + $cookies = [], + $files = [], + $server = [], + $content = null + ) { $uri = 'https://localhost/'.ltrim($uri, '/'); return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content); @@ -90,8 +97,16 @@ public function callSecure($method, $uri, $parameters = [], $cookies = [], $file * @param string $content * @return \Illuminate\Http\Response */ - public function route($method, $name, $routeParameters = [], $parameters = [], $cookies = [], $files = [], $server = [], $content = null) - { + public function route( + $method, + $name, + $routeParameters = [], + $parameters = [], + $cookies = [], + $files = [], + $server = [], + $content = null + ) { $uri = $this->app['url']->route($name, $routeParameters); return $this->response = $this->call($method, $uri, $parameters, $cookies, $files, $server, $content); diff --git a/src/Testing/AssertionsTrait.php b/src/Testing/AssertionsTrait.php index 31d9ce43..f5a9344a 100644 --- a/src/Testing/AssertionsTrait.php +++ b/src/Testing/AssertionsTrait.php @@ -28,7 +28,11 @@ public function assertResponseStatus($code) { $actual = $this->response->getStatusCode(); - return PHPUnit::assertEquals($code, $this->response->getStatusCode(), "Expected status code {$code}, got {$actual}."); + return PHPUnit::assertEquals( + $code, + $this->response->getStatusCode(), + "Expected status code {$code}, got {$actual}." + ); } /** diff --git a/src/helpers.php b/src/helpers.php index 5747474e..985a2fb2 100644 --- a/src/helpers.php +++ b/src/helpers.php @@ -103,8 +103,15 @@ function config($key = null, $default = null) * @param bool $httpOnly * @return \Symfony\Component\HttpFoundation\Cookie */ - function cookie($name = null, $value = null, $minutes = 0, $path = null, $domain = null, $secure = false, $httpOnly = true) - { + function cookie( + $name = null, + $value = null, + $minutes = 0, + $path = null, + $domain = null, + $secure = false, + $httpOnly = true + ) { $cookie = app('cookie'); if (is_null($name)) { diff --git a/tests/FullApplicationTest.php b/tests/FullApplicationTest.php index 6d3bb2d1..b83a697e 100644 --- a/tests/FullApplicationTest.php +++ b/tests/FullApplicationTest.php @@ -54,7 +54,7 @@ public function testRouteMiddleware() return response('Hello World'); }); - $app->get('/foo', ['middleware' => 'foo', function() { + $app->get('/foo', ['middleware' => 'foo', function () { return response('Hello World'); }]); @@ -74,13 +74,13 @@ public function testGroupRouteMiddleware() $app->routeMiddleware(['foo' => 'LumenTestMiddleware']); - $app->group(['middleware' => 'foo'], function($app) { + $app->group(['middleware' => 'foo'], function ($app) { $app->get('/', function () { return response('Hello World'); }); }); - $app->get('/foo', function() { + $app->get('/foo', function () { return response('Hello World'); }); @@ -145,7 +145,7 @@ public function testNamespacedControllerResponse() require_once __DIR__.'/fixtures/TestController.php'; - $app->group(['namespace' => 'Lumen\Tests'], function($app) { + $app->group(['namespace' => 'Lumen\Tests'], function ($app) { $app->get('/', 'TestController@action'); }); @@ -162,11 +162,11 @@ public function testGeneratingUrls() $app->instance('request', Request::create('http://lumen.com', 'GET')); unset($app->availableBindings['request']); - $app->get('/foo-bar', ['as' => 'foo', function() { + $app->get('/foo-bar', ['as' => 'foo', function () { // }]); - $app->get('/foo-bar/{baz}/{boom}', ['as' => 'bar', function() { + $app->get('/foo-bar/{baz}/{boom}', ['as' => 'bar', function () { // }]); @@ -182,15 +182,15 @@ public function testGeneratingUrlsForRegexParameters() $app->instance('request', Request::create('http://lumen.com', 'GET')); unset($app->availableBindings['request']); - $app->get('/foo-bar', ['as' => 'foo', function() { + $app->get('/foo-bar', ['as' => 'foo', function () { // }]); - $app->get('/foo-bar/{baz:[0-9]+}/{boom}', ['as' => 'bar', function() { + $app->get('/foo-bar/{baz:[0-9]+}/{boom}', ['as' => 'bar', function () { // }]); - $app->get('/foo-bar/{baz:[0-9]+}/{boom:[0-9]+}', ['as' => 'baz', function() { + $app->get('/foo-bar/{baz:[0-9]+}/{boom:[0-9]+}', ['as' => 'baz', function () { // }]); @@ -201,20 +201,27 @@ public function testGeneratingUrlsForRegexParameters() } } -class LumenTestService {} +class LumenTestService +{ +} -class LumenTestMiddleware { - public function handle($request, $next) { - return response('Middleware'); +class LumenTestMiddleware +{ + public function handle($request, $next) + { + return response('Middleware'); } } -class LumenTestController { +class LumenTestController +{ public $service; - public function __construct(LumenTestService $service) { + public function __construct(LumenTestService $service) + { $this->service = $service; } - public function action() { + public function action() + { return response(__CLASS__); } } diff --git a/tests/fixtures/TestController.php b/tests/fixtures/TestController.php index fdca2402..aae90236 100644 --- a/tests/fixtures/TestController.php +++ b/tests/fixtures/TestController.php @@ -1,7 +1,9 @@