From 1629d71687fc663246a98b96a683611f28698990 Mon Sep 17 00:00:00 2001 From: Noitran Date: Fri, 1 Feb 2019 03:31:34 +0200 Subject: [PATCH] Changed psr rules. --- README.md | 2 +- php_cs.php | 44 ++++++++++++++++++++++++++-- src/Console/TransformDocsCommand.php | 4 +-- src/ServiceProvider.php | 14 ++++----- tests/FullPackageTest.php | 4 +++ tests/bootstrap.php | 2 +- 6 files changed, 57 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index cd33bca..cfaaeee 100644 --- a/README.md +++ b/README.md @@ -132,7 +132,7 @@ $ php artisan opendox:transform ``` /api/documentation - Redoc UI interface -/api/console - Swagger UI with ability to test API +/api/console - Swagger UI with ability to send example requests /docs - Raw JSON documentation output, that can be used for external services ``` diff --git a/php_cs.php b/php_cs.php index 90fdcab..1bc8d5b 100644 --- a/php_cs.php +++ b/php_cs.php @@ -2,6 +2,7 @@ return PhpCsFixer\Config::create() ->setRules([ + 'psr0' => false, '@PSR2' => true, 'array_syntax' => [ 'syntax' => 'short', @@ -12,12 +13,15 @@ ], 'binary_operator_spaces' => [ 'align_double_arrow' => false, + 'align_equals' => false, ], 'trailing_comma_in_multiline_array' => true, 'whitespace_after_comma_in_array' => true, 'blank_line_after_opening_tag' => true, 'blank_line_before_return' => true, - 'cast_spaces' => true, + 'cast_spaces' => [ + 'space' => 'single', + ], 'function_typehint_space' => true, 'hash_to_slash_comment' => true, 'linebreak_after_opening_tag' => true, @@ -31,12 +35,48 @@ 'phpdoc_no_package' => true, 'phpdoc_order' => true, 'phpdoc_add_missing_param_annotation' => true, + 'phpdoc_separation' => true, + 'phpdoc_trim' => true, 'method_argument_space' => [ 'ensure_fully_multiline' => true, 'keep_multiple_spaces_after_comma' => true, ], + 'single_quote' => true, + 'phpdoc_no_empty_return' => false, + 'single_blank_line_before_namespace' => true, + 'blank_line_before_statement' => [ + 'statements' => [ + 'break', 'continue', 'declare', 'return', 'throw', 'try', + ], + ], + 'class_attributes_separation' => true, + 'concat_space' => [ + 'spacing' => 'one', + ], + 'declare_equal_normalize' => [ + 'space' => 'single', + ], + 'no_spaces_inside_parenthesis' => true, + 'ternary_operator_spaces' => true, + 'no_leading_import_slash' => true, + + // @PHP71Migration + 'ternary_to_null_coalescing' => true, + 'visibility_required' => true, + + // @PHP71Migration:risky + 'void_return' => true, + 'random_api_migration' => true, + 'pow_to_exponentiation' => true, + + // @Symfony:risky + 'dir_constant' => true, + 'function_to_constant' => true, + 'is_null' => true, + 'modernize_types_casting' => true, + 'no_alias_functions' => true, ]) - ->setRiskyAllowed(false) + ->setRiskyAllowed(true) ->setFinder( PhpCsFixer\Finder::create() ->in(__DIR__) diff --git a/src/Console/TransformDocsCommand.php b/src/Console/TransformDocsCommand.php index c067ae7..3b82700 100644 --- a/src/Console/TransformDocsCommand.php +++ b/src/Console/TransformDocsCommand.php @@ -29,7 +29,7 @@ class TransformDocsCommand extends Command * * @return void */ - public function handle() + public function handle(): void { $this->info('Transforming yaml to json.'); $settings = config('opendox.documentation_source'); @@ -54,7 +54,7 @@ public function handle() * * @return void */ - protected function convert(string $pathTo, string $fileName, string $fileExtension) + protected function convert(string $pathTo, string $fileName, string $fileExtension): void { $contents = $this->transform($pathTo . $fileName . '.' . $fileExtension); $saveToPath = config('opendox.documentation_source.save_to'); diff --git a/src/ServiceProvider.php b/src/ServiceProvider.php index 00e48e9..7d7d5d1 100644 --- a/src/ServiceProvider.php +++ b/src/ServiceProvider.php @@ -23,12 +23,12 @@ protected function getConfigPath(): string * * @return void */ - public function boot() + public function boot(): void { - $viewPath = __DIR__.'/../resources/views'; + $viewPath = __DIR__ . '/../resources/views'; $this->loadViewsFrom($viewPath, 'opendox'); - $configPath = __DIR__.'/../config/opendox.php'; + $configPath = __DIR__ . '/../config/opendox.php'; if (function_exists('config_path')) { $publishPath = config_path('opendox.php'); } else { @@ -36,8 +36,8 @@ public function boot() } $this->publishes([$configPath => $publishPath], 'config'); - $this->app->router->group(['namespace' => 'Noitran\Opendox'], function ($router) { - require __DIR__.'/routes/routes.php'; + $this->app->router->group(['namespace' => 'Noitran\Opendox'], function ($router): void { + require __DIR__ . '/routes/routes.php'; }); } @@ -46,9 +46,9 @@ public function boot() * * @return void */ - public function register() + public function register(): void { - $configPath = __DIR__.'/../config/opendox.php'; + $configPath = __DIR__ . '/../config/opendox.php'; $this->mergeConfigFrom($configPath, 'opendox'); $this->app->singleton('command.opendox.transform-docs', function () { diff --git a/tests/FullPackageTest.php b/tests/FullPackageTest.php index d6df111..62e8f50 100644 --- a/tests/FullPackageTest.php +++ b/tests/FullPackageTest.php @@ -17,6 +17,7 @@ protected function getStubDirectory(): string /** * @param mixed $fileName + * * @return void */ protected function copyStubFile($fileName): void @@ -44,6 +45,7 @@ public function itShouldTransformYamlToJson(): void /** * @test + * * @throws \Exception */ public function itShouldTestDocsRoute(): void @@ -57,6 +59,7 @@ public function itShouldTestDocsRoute(): void /** * @test + * * @throws \Exception */ public function itShouldTestRedocRoute(): void @@ -70,6 +73,7 @@ public function itShouldTestRedocRoute(): void /** * @test + * * @throws \Exception */ public function itShouldTestSwaggerRoute(): void diff --git a/tests/bootstrap.php b/tests/bootstrap.php index d1e202e..1ace423 100644 --- a/tests/bootstrap.php +++ b/tests/bootstrap.php @@ -1,6 +1,6 @@