From ae87913e38f7bf51d9a401e20870adf55ea10748 Mon Sep 17 00:00:00 2001 From: Maciej Iwanowski Date: Tue, 14 Apr 2015 22:21:52 +0200 Subject: [PATCH 1/2] some basic PSR fixes --- src/Console/Commands/ServeCommand.php | 4 ++-- src/Foundation/Composer.php | 7 +++---- src/Providers/CacheServiceProvider.php | 7 +++---- 3 files changed, 8 insertions(+), 10 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'); } - } From 0ca4a3c1a6e1ba382651860aada74feee6706b5f Mon Sep 17 00:00:00 2001 From: Maciej Iwanowski Date: Tue, 14 Apr 2015 23:02:47 +0200 Subject: [PATCH 2/2] rest of PSR updates --- src/Application.php | 39 ++++++++-------------- 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 | 6 ++-- src/Testing/ApplicationTrait.php | 23 ++++++++++--- src/Testing/AssertionsTrait.php | 6 +++- src/helpers.php | 11 ++++-- 9 files changed, 59 insertions(+), 46 deletions(-) diff --git a/src/Application.php b/src/Application.php index 2064f418..4bbbedd2 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,8 @@ protected function registerDatabaseBindings() { $this->singleton('db', function () { return $this->loadComponent( - 'database', [ - 'Illuminate\Database\DatabaseServiceProvider', - 'Illuminate\Pagination\PaginationServiceProvider'], + 'database', + ['Illuminate\Database\DatabaseServiceProvider', 'Illuminate\Pagination\PaginationServiceProvider'], 'db' ); }); @@ -487,9 +490,7 @@ protected function registerEventBindings() protected function registerErrorBindings() { if (! $this->bound('Illuminate\Contracts\Debug\ExceptionHandler')) { - $this->singleton( - 'Illuminate\Contracts\Debug\ExceptionHandler', 'Laravel\Lumen\Exceptions\Handler' - ); + $this->singleton('Illuminate\Contracts\Debug\ExceptionHandler', 'Laravel\Lumen\Exceptions\Handler'); } } @@ -1030,9 +1031,7 @@ protected function callTerminableMiddleware($response) $instance = $this->make($middleware); if ($instance instanceof TerminableMiddleware) { - $instance->terminate( - $this->make('request'), $response - ); + $instance->terminate($this->make('request'), $response); } } } @@ -1188,9 +1187,7 @@ protected function callControllerAction($routeInfo) if ($instance instanceof Routing\Controller) { return $this->callLumenController($instance, $method, $routeInfo); } else { - return $this->callControllerCallable( - [$instance, $method], array_values($routeInfo[2]) - ); + return $this->callControllerCallable([$instance, $method], array_values($routeInfo[2])); } } @@ -1204,18 +1201,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 +1224,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])); }); } 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..488ec5c0 100644 --- a/src/Console/Commands/ServeCommand.php +++ b/src/Console/Commands/ServeCommand.php @@ -48,8 +48,12 @@ 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..37b08d6f 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..e974c6a5 100644 --- a/src/Routing/ValidatesRequests.php +++ b/src/Routing/ValidatesRequests.php @@ -34,9 +34,9 @@ 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)) {