Skip to content

Commit

Permalink
php-cs-fixerの設定を更新。
Browse files Browse the repository at this point in the history
  • Loading branch information
logue committed Feb 24, 2018
1 parent d41ff4d commit b77c2db
Show file tree
Hide file tree
Showing 32 changed files with 313 additions and 193 deletions.
173 changes: 147 additions & 26 deletions .php_cs
@@ -1,32 +1,153 @@
<?php

$finder = Symfony\CS\Finder\DefaultFinder::create()
->exclude('bootstrap/cache')
->exclude('resources/assets')
->exclude('resources/views')
->exclude('storage')
->exclude('node_modules')
->in(__DIR__);
$finder = PhpCsFixer\Finder::create()
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true)
->exclude([
'.git',
'.idea',
'bower_components',
'node_modules',
'resources/lang',
'storage',
'vendor'
]);

$fixers = [
'-psr0',
'-phpdoc_no_empty_return',
'-phpdoc_no_package',
'-phpdoc_params',
'-phpdoc_short_description',
'-unalign_double_arrow',
'-unalign_equals',
'ereg_to_preg',
'ordered_use',
'php_unit_construct',
'php_unit_strict',
'phpdoc_order',
'short_array_syntax',
'strict',
'strict_param',
'@PSR2' => true,
'align_multiline_comment' => [
'comment_type' => 'phpdocs_only',
],
'array_syntax' => [
'syntax' => 'short',
],
'binary_operator_spaces' => [
'align_equals' => false,
'align_double_arrow' => true,
],
'blank_line_after_namespace' => true,
'blank_line_after_opening_tag' => true,
'blank_line_before_statement' => [
'statements' => [
'return',
'throw',
'try',
],
],
'braces' => true,
'cast_spaces' => true,
'class_definition' => true,
'concat_space' => [
'spacing' => 'none',
],
'declare_equal_normalize' => true,
'elseif' => true,
'encoding' => true,
'full_opening_tag' => true,
'function_declaration' => true,
'function_typehint_space' => true,
'general_phpdoc_annotation_remove' => [
'access',
'package',
'subpackage',
],
'hash_to_slash_comment' => true,
'heredoc_to_nowdoc' => true,
'include' => true,
'indentation_type' => true,
'line_ending' => true,
'lowercase_cast' => true,
'lowercase_constants' => true,
'lowercase_keywords' => true,
'magic_constant_casing' => true,
'method_argument_space' => true,
'method_separation' => true,
'native_function_casing' => false,
'new_with_braces' => true,
'no_alias_functions' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'no_closing_tag' => true,
'no_empty_phpdoc' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => [
'throw',
'use',
'useTrait',
'extra',
],
'no_leading_import_slash' => true,
'no_leading_namespace_whitespace' => true,
'no_mixed_echo_print' => [
'use' => 'echo',
],
'no_multiline_whitespace_around_double_arrow' => true,
'no_multiline_whitespace_before_semicolons' => true,
'no_short_bool_cast' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_spaces_after_function_name' => true,
'no_spaces_around_offset' => [
'inside',
'outside',
],
'no_spaces_inside_parenthesis' => true,
'no_trailing_comma_in_list_call' => true,
'no_trailing_comma_in_singleline_array' => true,
'no_trailing_whitespace' => true,
'no_trailing_whitespace_in_comment' => true,
'no_unneeded_control_parentheses' => true,
'no_unreachable_default_argument_value' => true,
'no_unused_imports' => true,
'no_useless_return' => true,
'no_whitespace_before_comma_in_array' => true,
'no_whitespace_in_blank_line' => true,
'normalize_index_brace' => true,
'object_operator_without_whitespace' => true,
'ordered_imports' => [
'sortAlgorithm' => 'alpha',
],
'phpdoc_align' => true,
'phpdoc_indent' => true,
'phpdoc_inline_tag' => true,
'phpdoc_no_alias_tag' => [
'type' => 'var',
],
'phpdoc_no_useless_inheritdoc' => true,
'phpdoc_order' => true,
'phpdoc_scalar' => true,
'phpdoc_separation' => true,
'phpdoc_single_line_var_spacing' => true,
'phpdoc_summary' => true,
'phpdoc_to_comment' => true,
'phpdoc_trim' => true,
'phpdoc_types' => true,
'phpdoc_var_without_name' => true,
'psr4' => true,
'self_accessor' => true,
'short_scalar_cast' => true,
'single_blank_line_at_eof' => true,
'single_blank_line_before_namespace' => true,
'single_class_element_per_statement' => true,
'single_import_per_statement' => true,
'single_line_after_imports' => true,
'single_quote' => true,
'space_after_semicolon' => true,
'standardize_not_equals' => true,
'switch_case_semicolon_to_colon' => true,
'switch_case_space' => true,
'ternary_operator_spaces' => true,
'trailing_comma_in_multiline_array' => true,
'trim_array_spaces' => true,
'unary_operator_spaces' => true,
'visibility_required' => [
'method',
'property',
],
'whitespace_after_comma_in_array' => true
];

return Symfony\CS\Config\Config::create()
->fixers($fixers)
->finder($finder)
->setUsingCache(true);
return PhpCsFixer\Config::create()
->setRules($fixers)
->setFinder($finder)
->setRiskyAllowed(true);
3 changes: 2 additions & 1 deletion app/Console/Kernel.php
Expand Up @@ -19,7 +19,8 @@ class Kernel extends ConsoleKernel
/**
* Define the application's command schedule.
*
* @param \Illuminate\Console\Scheduling\Schedule $schedule
* @param \Illuminate\Console\Scheduling\Schedule $schedule
*
* @return void
*/
protected function schedule(Schedule $schedule)
Expand Down
8 changes: 5 additions & 3 deletions app/Exceptions/Handler.php
Expand Up @@ -31,7 +31,8 @@ class Handler extends ExceptionHandler
*
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
*
* @param \Exception $exception
* @param \Exception $exception
*
* @return void
*/
public function report(Exception $exception)
Expand All @@ -42,8 +43,9 @@ public function report(Exception $exception)
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
* @param \Illuminate\Http\Request $request
* @param \Exception $exception
*
* @return \Illuminate\Http\Response
*/
public function render($request, Exception $exception)
Expand Down
18 changes: 10 additions & 8 deletions app/Http/Controllers/Auth/RegisterController.php
Expand Up @@ -2,11 +2,11 @@

namespace App\Http\Controllers\Auth;

use App\User;
use App\Http\Controllers\Controller;
use App\User;
use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Support\Facades\Hash;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;

class RegisterController extends Controller
{
Expand Down Expand Up @@ -43,29 +43,31 @@ public function __construct()
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @param array $data
*
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}

/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @param array $data
*
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password']),
]);
}
Expand Down
4 changes: 2 additions & 2 deletions app/Http/Controllers/Controller.php
Expand Up @@ -2,10 +2,10 @@

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{
Expand Down
12 changes: 6 additions & 6 deletions app/Http/Kernel.php
Expand Up @@ -51,12 +51,12 @@ class Kernel extends HttpKernel
* @var array
*/
protected $routeMiddleware = [
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'auth' => \Illuminate\Auth\Middleware\Authenticate::class,
'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
'bindings' => \Illuminate\Routing\Middleware\SubstituteBindings::class,
'cache.headers' => \Illuminate\Http\Middleware\SetCacheHeaders::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
'can' => \Illuminate\Auth\Middleware\Authorize::class,
'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
}
7 changes: 4 additions & 3 deletions app/Http/Middleware/RedirectIfAuthenticated.php
Expand Up @@ -10,9 +10,10 @@ class RedirectIfAuthenticated
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
*
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
Expand Down
2 changes: 1 addition & 1 deletion app/Http/Middleware/TrustProxies.php
Expand Up @@ -2,8 +2,8 @@

namespace App\Http\Middleware;

use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;

class TrustProxies extends Middleware
{
Expand Down
1 change: 0 additions & 1 deletion app/Providers/AuthServiceProvider.php
Expand Up @@ -2,7 +2,6 @@

namespace App\Providers;

use Illuminate\Support\Facades\Gate;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;

class AuthServiceProvider extends ServiceProvider
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/BroadcastServiceProvider.php
Expand Up @@ -2,8 +2,8 @@

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;

class BroadcastServiceProvider extends ServiceProvider
{
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/EventServiceProvider.php
Expand Up @@ -2,8 +2,8 @@

namespace App\Providers;

use Illuminate\Support\Facades\Event;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;

class EventServiceProvider extends ServiceProvider
{
Expand Down
2 changes: 1 addition & 1 deletion app/Providers/RouteServiceProvider.php
Expand Up @@ -2,8 +2,8 @@

namespace App\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;

class RouteServiceProvider extends ServiceProvider
{
Expand Down
2 changes: 1 addition & 1 deletion app/User.php
Expand Up @@ -2,8 +2,8 @@

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;

class User extends Authenticatable
{
Expand Down

0 comments on commit b77c2db

Please sign in to comment.