Skip to content

Commit d38286b

Browse files
authored
Merge pull request #20 from 39ff/19-refactor
refactor files.
2 parents 8f36dc1 + ab96469 commit d38286b

File tree

60 files changed

+610
-350
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+610
-350
lines changed

.php-cs-fixer.dist.php

Lines changed: 157 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,165 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
// https://gist.github.com/laravel-shift/cab527923ed2a109dda047b97d53c200
3+
use PhpCsFixer\Config;
4+
use PhpCsFixer\Finder;
25

3-
$finder = PhpCsFixer\Finder::create()
6+
$rules = [
7+
'array_indentation' => true,
8+
'array_syntax' => ['syntax' => 'short'],
9+
'binary_operator_spaces' => [
10+
'default' => 'single_space',
11+
'operators' => ['=>' => null],
12+
],
13+
'blank_line_after_namespace' => true,
14+
'blank_line_after_opening_tag' => true,
15+
'blank_line_before_statement' => [
16+
'statements' => ['return'],
17+
],
18+
'braces' => true,
19+
'cast_spaces' => true,
20+
'class_attributes_separation' => [
21+
'elements' => [
22+
'const' => 'one',
23+
'method' => 'one',
24+
'property' => 'one',
25+
'trait_import' => 'none',
26+
],
27+
],
28+
'class_definition' => [
29+
'multi_line_extends_each_single_line' => true,
30+
'single_item_single_line' => true,
31+
'single_line' => true,
32+
],
33+
'concat_space' => [
34+
'spacing' => 'none',
35+
],
36+
'constant_case' => ['case' => 'lower'],
37+
'declare_equal_normalize' => true,
38+
'elseif' => true,
39+
'encoding' => true,
40+
'full_opening_tag' => true,
41+
'fully_qualified_strict_types' => true, // added by Shift
42+
'function_declaration' => true,
43+
'function_typehint_space' => true,
44+
'general_phpdoc_tag_rename' => true,
45+
'heredoc_to_nowdoc' => true,
46+
'include' => true,
47+
'increment_style' => ['style' => 'post'],
48+
'indentation_type' => true,
49+
'linebreak_after_opening_tag' => true,
50+
'line_ending' => true,
51+
'lowercase_cast' => true,
52+
'lowercase_keywords' => true,
53+
'lowercase_static_reference' => true, // added from Symfony
54+
'magic_method_casing' => true, // added from Symfony
55+
'magic_constant_casing' => true,
56+
'method_argument_space' => [
57+
'on_multiline' => 'ignore',
58+
],
59+
'multiline_whitespace_before_semicolons' => [
60+
'strategy' => 'no_multi_line',
61+
],
62+
'native_function_casing' => true,
63+
'no_alias_functions' => true,
64+
'no_extra_blank_lines' => [
65+
'tokens' => [
66+
'extra',
67+
'throw',
68+
'use',
69+
],
70+
],
71+
'no_blank_lines_after_class_opening' => true,
72+
'no_blank_lines_after_phpdoc' => true,
73+
'no_closing_tag' => true,
74+
'no_empty_phpdoc' => true,
75+
'no_empty_statement' => true,
76+
'no_leading_import_slash' => true,
77+
'no_leading_namespace_whitespace' => true,
78+
'no_mixed_echo_print' => [
79+
'use' => 'echo',
80+
],
81+
'no_multiline_whitespace_around_double_arrow' => true,
82+
'no_short_bool_cast' => true,
83+
'no_singleline_whitespace_before_semicolons' => true,
84+
'no_spaces_after_function_name' => true,
85+
'no_spaces_around_offset' => [
86+
'positions' => ['inside', 'outside'],
87+
],
88+
'no_spaces_inside_parenthesis' => true,
89+
'no_trailing_comma_in_list_call' => true,
90+
'no_trailing_comma_in_singleline_array' => true,
91+
'no_trailing_whitespace' => true,
92+
'no_trailing_whitespace_in_comment' => true,
93+
'no_unneeded_control_parentheses' => [
94+
'statements' => ['break', 'clone', 'continue', 'echo_print', 'return', 'switch_case', 'yield'],
95+
],
96+
'no_unreachable_default_argument_value' => true,
97+
'no_useless_return' => true,
98+
'no_whitespace_before_comma_in_array' => true,
99+
'no_whitespace_in_blank_line' => true,
100+
'normalize_index_brace' => true,
101+
'not_operator_with_successor_space' => true,
102+
'object_operator_without_whitespace' => true,
103+
'ordered_imports' => ['sort_algorithm' => 'alpha'],
104+
'psr_autoloading' => true,
105+
'phpdoc_indent' => true,
106+
'phpdoc_inline_tag_normalizer' => true,
107+
'phpdoc_no_access' => true,
108+
'phpdoc_no_package' => true,
109+
'phpdoc_no_useless_inheritdoc' => true,
110+
'phpdoc_scalar' => true,
111+
'phpdoc_single_line_var_spacing' => true,
112+
'phpdoc_summary' => false,
113+
'phpdoc_to_comment' => false, // override to preserve user preference
114+
'phpdoc_tag_type' => true,
115+
'phpdoc_trim' => true,
116+
'phpdoc_types' => true,
117+
'phpdoc_var_without_name' => true,
118+
'self_accessor' => true,
119+
'short_scalar_cast' => true,
120+
'simplified_null_return' => false, // disabled as "risky"
121+
'single_blank_line_at_eof' => true,
122+
'single_blank_line_before_namespace' => true,
123+
'single_class_element_per_statement' => [
124+
'elements' => ['const', 'property'],
125+
],
126+
'single_import_per_statement' => true,
127+
'single_line_after_imports' => true,
128+
'single_line_comment_style' => [
129+
'comment_types' => ['hash'],
130+
],
131+
'single_quote' => true,
132+
'space_after_semicolon' => true,
133+
'standardize_not_equals' => true,
134+
'switch_case_semicolon_to_colon' => true,
135+
'switch_case_space' => true,
136+
'ternary_operator_spaces' => true,
137+
'trailing_comma_in_multiline' => ['elements' => ['arrays']],
138+
'trim_array_spaces' => true,
139+
'unary_operator_spaces' => true,
140+
'visibility_required' => [
141+
'elements' => ['method', 'property'],
142+
],
143+
'whitespace_after_comma_in_array' => true,
144+
];
145+
146+
147+
$finder = Finder::create()
4148
->in([
5149
__DIR__ . '/app',
6150
__DIR__ . '/config',
7-
__DIR__ . '/database/factories',
8-
__DIR__ . '/database/seeders',
151+
__DIR__ . '/database',
152+
__DIR__ . '/resources',
9153
__DIR__ . '/routes',
10154
__DIR__ . '/tests',
11-
]);
12-
13-
$config = new PhpCsFixer\Config();
155+
])
156+
->name('*.php')
157+
->notName('*.blade.php')
158+
->ignoreDotFiles(true)
159+
->ignoreVCS(true);
14160

15-
return $config
161+
return (new Config)
162+
->setFinder($finder)
163+
->setRules($rules)
16164
->setRiskyAllowed(true)
17-
->setRules([
18-
'@PhpCsFixer:risky' => true,
19-
'blank_line_after_opening_tag' => false,
20-
'linebreak_after_opening_tag' => false,
21-
'phpdoc_types_order' => [
22-
'null_adjustment' => 'always_last',
23-
'sort_algorithm' => 'none',
24-
],
25-
'no_superfluous_phpdoc_tags' => false,
26-
'global_namespace_import' => [
27-
'import_classes' => true,
28-
'import_constants' => true,
29-
'import_functions' => true,
30-
],
31-
'php_unit_test_case_static_method_calls' => [
32-
'call_type' => 'this'
33-
],
34-
'phpdoc_align' => [
35-
'align' => 'left',
36-
],
37-
'not_operator_with_successor_space' => true,
38-
'blank_line_after_namespace' => true,
39-
'date_time_immutable' => true,
40-
'declare_parentheses' => true,
41-
'final_public_method_for_abstract_class' => true,
42-
'mb_str_functions' => true,
43-
'simplified_if_return' => false,
44-
'simplified_null_return' => false,
45-
])
46-
->setFinder($finder);
165+
->setUsingCache(true);

app/Http/Controllers/Api/SquidAllowedIpController.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,22 @@
1414

1515
class SquidAllowedIpController extends Controller
1616
{
17-
public function search(SearchRequest $request,SearchAction $action) : SquidAllowedIpCollection{
17+
public function search(SearchRequest $request, SearchAction $action) : SquidAllowedIpCollection
18+
{
1819
$query = $request->searchSquidAllowedIp();
1920

2021
return new SquidAllowedIpCollection($action($query));
2122
}
2223

23-
public function create(CreateRequest $request,CreateAction $action) : SquidAllowedIpResource{
24+
public function create(CreateRequest $request, CreateAction $action) : SquidAllowedIpResource
25+
{
2426
$squidAllowedIp = $request->createSquidAllowedIp();
2527

2628
return new SquidAllowedIpResource($action($squidAllowedIp));
2729
}
2830

29-
public function destroy(DestroyRequest $request,DestroyAction $action): SquidAllowedIpResource{
31+
public function destroy(DestroyRequest $request, DestroyAction $action): SquidAllowedIpResource
32+
{
3033
$squidAllowedIp = $request->destroySquidAllowedIp();
3134

3235
return new SquidAllowedIpResource($action($squidAllowedIp));

app/Http/Controllers/Api/SquidUserController.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,29 @@
1616

1717
class SquidUserController extends Controller
1818
{
19-
public function search(SearchRequest $request, SearchAction $action) : SquidUserCollection{
19+
public function search(SearchRequest $request, SearchAction $action) : SquidUserCollection
20+
{
2021
$query = $request->searchSquidUser();
2122

2223
return new SquidUserCollection($action($query));
2324
}
2425

25-
public function create(CreateRequest $request, CreateAction $action) : SquidUserResource{
26+
public function create(CreateRequest $request, CreateAction $action) : SquidUserResource
27+
{
2628
$user = $request->createSquidUser();
2729

2830
return new SquidUserResource($action($user));
2931
}
3032

31-
public function modify(ModifyRequest $request, ModifyAction $action) : SquidUserResource{
33+
public function modify(ModifyRequest $request, ModifyAction $action) : SquidUserResource
34+
{
3235
$user = $request->modifySquidUser();
3336

3437
return new SquidUserResource($action($user));
3538
}
3639

37-
public function destroy(DestroyRequest $request, DestroyAction $action) : SquidUserResource{
40+
public function destroy(DestroyRequest $request, DestroyAction $action) : SquidUserResource
41+
{
3842
$user = $request->destroySquidUser();
3943

4044
return new SquidUserResource($action($user));

app/Http/Controllers/Api/UserController.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,38 +3,42 @@
33
namespace App\Http\Controllers\Api;
44

55
use App\Http\Controllers\Controller;
6-
use App\Http\Requests\User\SearchRequest;
76
use App\Http\Requests\User\CreateRequest;
87
use App\Http\Requests\User\DestroyRequest;
98
use App\Http\Requests\User\ModifyRequest;
9+
use App\Http\Requests\User\SearchRequest;
1010
use App\Http\Resources\UserCollection;
1111
use App\Http\Resources\UserResource;
12-
use App\UseCases\User\SearchAction;
1312
use App\UseCases\User\CreateAction;
1413
use App\UseCases\User\DestroyAction;
1514
use App\UseCases\User\ModifyAction;
15+
use App\UseCases\User\SearchAction;
1616

1717
class UserController extends Controller
1818
{
19-
public function search(SearchRequest $request, SearchAction $action) : UserCollection{
19+
public function search(SearchRequest $request, SearchAction $action) : UserCollection
20+
{
2021
$query = $request->searchUser();
2122

2223
return new UserCollection($action($query));
2324
}
2425

25-
public function create(CreateRequest $request, CreateAction $action) : UserResource{
26+
public function create(CreateRequest $request, CreateAction $action) : UserResource
27+
{
2628
$user = $request->createUser();
2729

2830
return new UserResource($action($user));
2931
}
3032

31-
public function modify(ModifyRequest $request, ModifyAction $action) : UserResource{
33+
public function modify(ModifyRequest $request, ModifyAction $action) : UserResource
34+
{
3235
$user = $request->modifyUser();
3336

3437
return new UserResource($action($user));
3538
}
3639

37-
public function destroy(DestroyRequest $request, DestroyAction $action) : UserResource{
40+
public function destroy(DestroyRequest $request, DestroyAction $action) : UserResource
41+
{
3842
$user = $request->destroyUser();
3943

4044
return new UserResource($action($user));

app/Http/Controllers/Auth/RegisterController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
namespace App\Http\Controllers\Auth;
44

55
use App\Http\Controllers\Controller;
6-
use App\Providers\RouteServiceProvider;
76
use App\Models\User;
7+
use App\Providers\RouteServiceProvider;
88
use Illuminate\Foundation\Auth\RegistersUsers;
99
use Illuminate\Support\Facades\Hash;
1010
use Illuminate\Support\Facades\Validator;

app/Http/Controllers/Gui/SquidAllowedIpController.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,29 @@
1212

1313
class SquidAllowedIpController extends Controller
1414
{
15-
public function search(SearchRequest $request,SearchAction $action){
16-
return view('squidallowedips.search',[
17-
'ips'=>$action($request->searchSquidAllowedIp())
15+
public function search(SearchRequest $request, SearchAction $action)
16+
{
17+
return view('squidallowedips.search', [
18+
'ips'=>$action($request->searchSquidAllowedIp()),
1819
]);
1920
}
2021

21-
public function creator(){
22+
public function creator()
23+
{
2224
return view('squidallowedips.creator');
2325
}
2426

25-
public function create(CreateRequest $request,CreateAction $action){
27+
public function create(CreateRequest $request, CreateAction $action)
28+
{
2629
$action($request->createSquidAllowedIp());
27-
return redirect()->route('ip.search',$request->user()->id);
30+
31+
return redirect()->route('ip.search', $request->user()->id);
2832
}
2933

30-
public function destroy(DestroyRequest $request,DestroyAction $action){
34+
public function destroy(DestroyRequest $request, DestroyAction $action)
35+
{
3136
$action($request->destroySquidAllowedIp());
32-
return redirect()->route('ip.search',$request->user()->id);
37+
38+
return redirect()->route('ip.search', $request->user()->id);
3339
}
3440
}

0 commit comments

Comments
 (0)