Skip to content

Commit c9edfec

Browse files
committed
Improve PHP CS Fixer config
1 parent 3ef71ed commit c9edfec

27 files changed

+135
-180
lines changed

.php-cs-fixer.dist.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?php
2+
3+
// Reference: http://cs.sensiolabs.org/
4+
5+
return (new PhpCsFixer\Config())
6+
->setUsingCache(false)
7+
->setRiskyAllowed(true)
8+
->setRules([
9+
'@PHP70Migration' => true,
10+
'@PHP71Migration' => true,
11+
'@PSR2' => true,
12+
'@Symfony' => true,
13+
'array_syntax' => ['syntax' => 'short'],
14+
'increment_style' => ['style' => 'post'],
15+
'multiline_whitespace_before_semicolons' => true,
16+
'array_indentation' => true,
17+
'not_operator_with_successor_space' => true,
18+
'ordered_imports' => ['sort_algorithm' => 'length'],
19+
'php_unit_method_casing' => ['case' => 'snake_case'],
20+
'semicolon_after_instruction' => false,
21+
'single_line_throw' => false,
22+
'yoda_style' => false,
23+
'strict_comparison' => true,
24+
'yoda_style' => false,
25+
'single_line_throw' => false,
26+
'php_unit_method_casing' => ['case' => 'snake_case'],
27+
'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
28+
]);

.php_cs.dist

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Console/CreateMiddleware.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ class CreateMiddleware extends GeneratorCommand
3030

3131
/**
3232
* Get the stub file for the generator.
33-
*
34-
* @return string
3533
*/
3634
protected function getStub(): string
3735
{
@@ -41,8 +39,7 @@ protected function getStub(): string
4139
/**
4240
* Get the default namespace for the class.
4341
*
44-
* @param string $rootNamespace
45-
* @return string
42+
* @param string $rootNamespace
4643
*/
4744
protected function getDefaultNamespace($rootNamespace): string
4845
{
@@ -51,8 +48,6 @@ protected function getDefaultNamespace($rootNamespace): string
5148

5249
/**
5350
* Get the console command arguments.
54-
*
55-
* @return array
5651
*/
5752
protected function getArguments(): array
5853
{
@@ -63,8 +58,6 @@ protected function getArguments(): array
6358

6459
/**
6560
* Get the console command options.
66-
*
67-
* @return array
6861
*/
6962
protected function getOptions(): array
7063
{

src/Directive.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ class Directive
77
/**
88
* Compiles the "@inertia" directive.
99
*
10-
* @param string $expression
11-
* @return string
10+
* @param string $expression
1211
*/
1312
public static function compile($expression = ''): string
1413
{
@@ -32,8 +31,7 @@ public static function compile($expression = ''): string
3231
/**
3332
* Compiles the "@inertiaHead" directive.
3433
*
35-
* @param string $expression
36-
* @return string
34+
* @param string $expression
3735
*/
3836
public static function compileHead($expression = ''): string
3937
{

src/Inertia.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
namespace Inertia;
44

5-
use Illuminate\Contracts\Support\Arrayable;
65
use Illuminate\Support\Facades\Facade;
6+
use Illuminate\Contracts\Support\Arrayable;
77

88
/**
99
* @method static void setRootView(string $name)

src/Middleware.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ class Middleware
2323
*
2424
* @see https://inertiajs.com/asset-versioning
2525
*
26-
* @param \Illuminate\Http\Request $request
2726
* @return string|null
2827
*/
2928
public function version(Request $request)
@@ -48,7 +47,6 @@ public function version(Request $request)
4847
*
4948
* @see https://inertiajs.com/shared-data
5049
*
51-
* @param \Illuminate\Http\Request $request
5250
* @return array
5351
*/
5452
public function share(Request $request)
@@ -65,7 +63,6 @@ public function share(Request $request)
6563
*
6664
* @see https://inertiajs.com/server-side-setup#root-template
6765
*
68-
* @param Request $request
6966
* @return string
7067
*/
7168
public function rootView(Request $request)
@@ -76,8 +73,6 @@ public function rootView(Request $request)
7673
/**
7774
* Handle the incoming request.
7875
*
79-
* @param \Illuminate\Http\Request $request
80-
* @param Closure $next
8176
* @return Response
8277
*/
8378
public function handle(Request $request, Closure $next)
@@ -114,10 +109,6 @@ public function handle(Request $request, Closure $next)
114109
/**
115110
* Determines what to do when an Inertia action returned with no response.
116111
* By default, we'll redirect the user back to where they came from.
117-
*
118-
* @param Request $request
119-
* @param Response $response
120-
* @return Response
121112
*/
122113
public function onEmptyResponse(Request $request, Response $response): Response
123114
{
@@ -127,10 +118,6 @@ public function onEmptyResponse(Request $request, Response $response): Response
127118
/**
128119
* Determines what to do when the Inertia asset version has changed.
129120
* By default, we'll initiate a client-side location visit to force an update.
130-
*
131-
* @param Request $request
132-
* @param Response $response
133-
* @return Response
134121
*/
135122
public function onVersionChange(Request $request, Response $response): Response
136123
{
@@ -145,7 +132,6 @@ public function onVersionChange(Request $request, Response $response): Response
145132
* Resolves and prepares validation errors in such
146133
* a way that they are easier to use client-side.
147134
*
148-
* @param Request $request
149135
* @return object
150136
*/
151137
public function resolveValidationErrors(Request $request)

src/Response.php

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
namespace Inertia;
44

55
use Closure;
6+
use Illuminate\Support\Arr;
7+
use Illuminate\Http\Request;
8+
use Illuminate\Http\JsonResponse;
9+
use Illuminate\Support\Facades\App;
610
use GuzzleHttp\Promise\PromiseInterface;
11+
use Illuminate\Support\Traits\Macroable;
712
use Illuminate\Contracts\Support\Arrayable;
813
use Illuminate\Contracts\Support\Responsable;
9-
use Illuminate\Http\JsonResponse;
10-
use Illuminate\Http\Request;
1114
use Illuminate\Http\Resources\Json\JsonResource;
1215
use Illuminate\Http\Resources\Json\ResourceResponse;
13-
use Illuminate\Support\Arr;
14-
use Illuminate\Support\Facades\App;
1516
use Illuminate\Support\Facades\Response as ResponseFactory;
16-
use Illuminate\Support\Traits\Macroable;
1717

1818
class Response implements Responsable
1919
{
@@ -26,10 +26,7 @@ class Response implements Responsable
2626
protected $viewData = [];
2727

2828
/**
29-
* @param string $component
30-
* @param array|Arrayable $props
31-
* @param string $rootView
32-
* @param string $version
29+
* @param array|Arrayable $props
3330
*/
3431
public function __construct(string $component, $props, string $rootView = 'app', string $version = '')
3532
{
@@ -40,8 +37,9 @@ public function __construct(string $component, $props, string $rootView = 'app',
4037
}
4138

4239
/**
43-
* @param string|array $key
44-
* @param mixed|null $value
40+
* @param string|array $key
41+
* @param mixed|null $value
42+
*
4543
* @return $this
4644
*/
4745
public function with($key, $value = null): self
@@ -56,8 +54,9 @@ public function with($key, $value = null): self
5654
}
5755

5856
/**
59-
* @param string|array $key
60-
* @param mixed|null $value
57+
* @param string|array $key
58+
* @param mixed|null $value
59+
*
6160
* @return $this
6261
*/
6362
public function withViewData($key, $value = null): self
@@ -81,7 +80,8 @@ public function rootView(string $rootView): self
8180
/**
8281
* Create an HTTP response that represents the object.
8382
*
84-
* @param \Illuminate\Http\Request $request
83+
* @param \Illuminate\Http\Request $request
84+
*
8585
* @return \Symfony\Component\HttpFoundation\Response
8686
*/
8787
public function toResponse($request)
@@ -112,11 +112,6 @@ public function toResponse($request)
112112

113113
/**
114114
* Resolve all necessary class instances in the given props.
115-
*
116-
* @param array $props
117-
* @param \Illuminate\Http\Request $request
118-
* @param bool $unpackDotProps
119-
* @return array
120115
*/
121116
public function resolvePropertyInstances(array $props, Request $request, bool $unpackDotProps = true): array
122117
{

src/ResponseFactory.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
namespace Inertia;
44

55
use Closure;
6-
use Illuminate\Contracts\Support\Arrayable;
7-
use Illuminate\Http\RedirectResponse;
86
use Illuminate\Support\Arr;
97
use Illuminate\Support\Facades\App;
8+
use Illuminate\Http\RedirectResponse;
109
use Illuminate\Support\Facades\Request;
11-
use Illuminate\Support\Facades\Response as BaseResponse;
1210
use Illuminate\Support\Traits\Macroable;
11+
use Illuminate\Contracts\Support\Arrayable;
12+
use Illuminate\Support\Facades\Response as BaseResponse;
1313

1414
class ResponseFactory
1515
{
@@ -30,8 +30,8 @@ public function setRootView(string $name): void
3030
}
3131

3232
/**
33-
* @param string|array|Arrayable $key
34-
* @param mixed|null $value
33+
* @param string|array|Arrayable $key
34+
* @param mixed|null $value
3535
*/
3636
public function share($key, $value = null): void
3737
{
@@ -45,8 +45,8 @@ public function share($key, $value = null): void
4545
}
4646

4747
/**
48-
* @param string|null $key
49-
* @param null|mixed $default
48+
* @param mixed|null $default
49+
*
5050
* @return mixed
5151
*/
5252
public function getShared(string $key = null, $default = null)
@@ -64,7 +64,7 @@ public function flushShared(): void
6464
}
6565

6666
/**
67-
* @param Closure|string|null $version
67+
* @param Closure|string|null $version
6868
*/
6969
public function version($version): void
7070
{
@@ -86,9 +86,7 @@ public function lazy(callable $callback): LazyProp
8686
}
8787

8888
/**
89-
* @param string $component
90-
* @param array|Arrayable $props
91-
* @return Response
89+
* @param array|Arrayable $props
9290
*/
9391
public function render(string $component, $props = []): Response
9492
{
@@ -105,7 +103,7 @@ public function render(string $component, $props = []): Response
105103
}
106104

107105
/**
108-
* @param string|RedirectResponse $url
106+
* @param string|RedirectResponse $url
109107
*/
110108
public function location($url): \Symfony\Component\HttpFoundation\Response
111109
{

src/ServiceProvider.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
namespace Inertia;
44

5-
use Illuminate\Foundation\Testing\TestResponse as LegacyTestResponse;
5+
use LogicException;
6+
use Inertia\Ssr\Gateway;
7+
use ReflectionException;
68
use Illuminate\Http\Request;
9+
use Inertia\Ssr\HttpGateway;
710
use Illuminate\Routing\Router;
8-
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
9-
use Illuminate\Testing\TestResponse;
1011
use Illuminate\View\FileViewFinder;
11-
use Inertia\Ssr\Gateway;
12-
use Inertia\Ssr\HttpGateway;
12+
use Illuminate\Testing\TestResponse;
1313
use Inertia\Testing\TestResponseMacros;
14-
use LogicException;
15-
use ReflectionException;
14+
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
15+
use Illuminate\Foundation\Testing\TestResponse as LegacyTestResponse;
1616

1717
class ServiceProvider extends BaseServiceProvider
1818
{

src/Ssr/Gateway.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ interface Gateway
66
{
77
/**
88
* Dispatch the Inertia page to the Server Side Rendering engine.
9-
*
10-
* @param array $page
11-
* @return Response|null
129
*/
1310
public function dispatch(array $page): ?Response;
1411
}

0 commit comments

Comments
 (0)