Skip to content

Commit

Permalink
Improve PHP CS Fixer config
Browse files Browse the repository at this point in the history
  • Loading branch information
reinink committed Jan 12, 2023
1 parent 3ef71ed commit c9edfec
Show file tree
Hide file tree
Showing 27 changed files with 135 additions and 180 deletions.
28 changes: 28 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

// Reference: http://cs.sensiolabs.org/

return (new PhpCsFixer\Config())
->setUsingCache(false)
->setRiskyAllowed(true)
->setRules([
'@PHP70Migration' => true,
'@PHP71Migration' => true,
'@PSR2' => true,
'@Symfony' => true,
'array_syntax' => ['syntax' => 'short'],
'increment_style' => ['style' => 'post'],
'multiline_whitespace_before_semicolons' => true,
'array_indentation' => true,
'not_operator_with_successor_space' => true,
'ordered_imports' => ['sort_algorithm' => 'length'],
'php_unit_method_casing' => ['case' => 'snake_case'],
'semicolon_after_instruction' => false,
'single_line_throw' => false,
'yoda_style' => false,
'strict_comparison' => true,
'yoda_style' => false,
'single_line_throw' => false,
'php_unit_method_casing' => ['case' => 'snake_case'],
'global_namespace_import' => ['import_classes' => true, 'import_constants' => true, 'import_functions' => true],
]);
20 changes: 0 additions & 20 deletions .php_cs.dist

This file was deleted.

9 changes: 1 addition & 8 deletions src/Console/CreateMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ class CreateMiddleware extends GeneratorCommand

/**
* Get the stub file for the generator.
*
* @return string
*/
protected function getStub(): string
{
Expand All @@ -41,8 +39,7 @@ protected function getStub(): string
/**
* Get the default namespace for the class.
*
* @param string $rootNamespace
* @return string
* @param string $rootNamespace
*/
protected function getDefaultNamespace($rootNamespace): string
{
Expand All @@ -51,8 +48,6 @@ protected function getDefaultNamespace($rootNamespace): string

/**
* Get the console command arguments.
*
* @return array
*/
protected function getArguments(): array
{
Expand All @@ -63,8 +58,6 @@ protected function getArguments(): array

/**
* Get the console command options.
*
* @return array
*/
protected function getOptions(): array
{
Expand Down
6 changes: 2 additions & 4 deletions src/Directive.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ class Directive
/**
* Compiles the "@inertia" directive.
*
* @param string $expression
* @return string
* @param string $expression
*/
public static function compile($expression = ''): string
{
Expand All @@ -32,8 +31,7 @@ public static function compile($expression = ''): string
/**
* Compiles the "@inertiaHead" directive.
*
* @param string $expression
* @return string
* @param string $expression
*/
public static function compileHead($expression = ''): string
{
Expand Down
2 changes: 1 addition & 1 deletion src/Inertia.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

namespace Inertia;

use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Facades\Facade;
use Illuminate\Contracts\Support\Arrayable;

/**
* @method static void setRootView(string $name)
Expand Down
14 changes: 0 additions & 14 deletions src/Middleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ class Middleware
*
* @see https://inertiajs.com/asset-versioning
*
* @param \Illuminate\Http\Request $request
* @return string|null
*/
public function version(Request $request)
Expand All @@ -48,7 +47,6 @@ public function version(Request $request)
*
* @see https://inertiajs.com/shared-data
*
* @param \Illuminate\Http\Request $request
* @return array
*/
public function share(Request $request)
Expand All @@ -65,7 +63,6 @@ public function share(Request $request)
*
* @see https://inertiajs.com/server-side-setup#root-template
*
* @param Request $request
* @return string
*/
public function rootView(Request $request)
Expand All @@ -76,8 +73,6 @@ public function rootView(Request $request)
/**
* Handle the incoming request.
*
* @param \Illuminate\Http\Request $request
* @param Closure $next
* @return Response
*/
public function handle(Request $request, Closure $next)
Expand Down Expand Up @@ -114,10 +109,6 @@ public function handle(Request $request, Closure $next)
/**
* Determines what to do when an Inertia action returned with no response.
* By default, we'll redirect the user back to where they came from.
*
* @param Request $request
* @param Response $response
* @return Response
*/
public function onEmptyResponse(Request $request, Response $response): Response
{
Expand All @@ -127,10 +118,6 @@ public function onEmptyResponse(Request $request, Response $response): Response
/**
* Determines what to do when the Inertia asset version has changed.
* By default, we'll initiate a client-side location visit to force an update.
*
* @param Request $request
* @param Response $response
* @return Response
*/
public function onVersionChange(Request $request, Response $response): Response
{
Expand All @@ -145,7 +132,6 @@ public function onVersionChange(Request $request, Response $response): Response
* Resolves and prepares validation errors in such
* a way that they are easier to use client-side.
*
* @param Request $request
* @return object
*/
public function resolveValidationErrors(Request $request)
Expand Down
33 changes: 14 additions & 19 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
namespace Inertia;

use Closure;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use Illuminate\Http\JsonResponse;
use Illuminate\Support\Facades\App;
use GuzzleHttp\Promise\PromiseInterface;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Contracts\Support\Responsable;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Http\Resources\Json\ResourceResponse;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Response as ResponseFactory;
use Illuminate\Support\Traits\Macroable;

class Response implements Responsable
{
Expand All @@ -26,10 +26,7 @@ class Response implements Responsable
protected $viewData = [];

/**
* @param string $component
* @param array|Arrayable $props
* @param string $rootView
* @param string $version
* @param array|Arrayable $props
*/
public function __construct(string $component, $props, string $rootView = 'app', string $version = '')
{
Expand All @@ -40,8 +37,9 @@ public function __construct(string $component, $props, string $rootView = 'app',
}

/**
* @param string|array $key
* @param mixed|null $value
* @param string|array $key
* @param mixed|null $value
*
* @return $this
*/
public function with($key, $value = null): self
Expand All @@ -56,8 +54,9 @@ public function with($key, $value = null): self
}

/**
* @param string|array $key
* @param mixed|null $value
* @param string|array $key
* @param mixed|null $value
*
* @return $this
*/
public function withViewData($key, $value = null): self
Expand All @@ -81,7 +80,8 @@ public function rootView(string $rootView): self
/**
* Create an HTTP response that represents the object.
*
* @param \Illuminate\Http\Request $request
* @param \Illuminate\Http\Request $request
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function toResponse($request)
Expand Down Expand Up @@ -112,11 +112,6 @@ public function toResponse($request)

/**
* Resolve all necessary class instances in the given props.
*
* @param array $props
* @param \Illuminate\Http\Request $request
* @param bool $unpackDotProps
* @return array
*/
public function resolvePropertyInstances(array $props, Request $request, bool $unpackDotProps = true): array
{
Expand Down
22 changes: 10 additions & 12 deletions src/ResponseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
namespace Inertia;

use Closure;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Arr;
use Illuminate\Support\Facades\App;
use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Request;
use Illuminate\Support\Facades\Response as BaseResponse;
use Illuminate\Support\Traits\Macroable;
use Illuminate\Contracts\Support\Arrayable;
use Illuminate\Support\Facades\Response as BaseResponse;

class ResponseFactory
{
Expand All @@ -30,8 +30,8 @@ public function setRootView(string $name): void
}

/**
* @param string|array|Arrayable $key
* @param mixed|null $value
* @param string|array|Arrayable $key
* @param mixed|null $value
*/
public function share($key, $value = null): void
{
Expand All @@ -45,8 +45,8 @@ public function share($key, $value = null): void
}

/**
* @param string|null $key
* @param null|mixed $default
* @param mixed|null $default
*
* @return mixed
*/
public function getShared(string $key = null, $default = null)
Expand All @@ -64,7 +64,7 @@ public function flushShared(): void
}

/**
* @param Closure|string|null $version
* @param Closure|string|null $version
*/
public function version($version): void
{
Expand All @@ -86,9 +86,7 @@ public function lazy(callable $callback): LazyProp
}

/**
* @param string $component
* @param array|Arrayable $props
* @return Response
* @param array|Arrayable $props
*/
public function render(string $component, $props = []): Response
{
Expand All @@ -105,7 +103,7 @@ public function render(string $component, $props = []): Response
}

/**
* @param string|RedirectResponse $url
* @param string|RedirectResponse $url
*/
public function location($url): \Symfony\Component\HttpFoundation\Response
{
Expand Down
14 changes: 7 additions & 7 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

namespace Inertia;

use Illuminate\Foundation\Testing\TestResponse as LegacyTestResponse;
use LogicException;
use Inertia\Ssr\Gateway;
use ReflectionException;
use Illuminate\Http\Request;
use Inertia\Ssr\HttpGateway;
use Illuminate\Routing\Router;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use Illuminate\Testing\TestResponse;
use Illuminate\View\FileViewFinder;
use Inertia\Ssr\Gateway;
use Inertia\Ssr\HttpGateway;
use Illuminate\Testing\TestResponse;
use Inertia\Testing\TestResponseMacros;
use LogicException;
use ReflectionException;
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
use Illuminate\Foundation\Testing\TestResponse as LegacyTestResponse;

class ServiceProvider extends BaseServiceProvider
{
Expand Down
3 changes: 0 additions & 3 deletions src/Ssr/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@ interface Gateway
{
/**
* Dispatch the Inertia page to the Server Side Rendering engine.
*
* @param array $page
* @return Response|null
*/
public function dispatch(array $page): ?Response;
}
3 changes: 0 additions & 3 deletions src/Ssr/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ class Response

/**
* Prepare the Inertia Server Side Rendering (SSR) response.
*
* @param string $head
* @param string $body
*/
public function __construct(string $head, string $body)
{
Expand Down
Loading

0 comments on commit c9edfec

Please sign in to comment.