Skip to content

Commit

Permalink
Changed psr rules.
Browse files Browse the repository at this point in the history
  • Loading branch information
noitran committed Feb 1, 2019
1 parent b8941e5 commit 1629d71
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
44 changes: 42 additions & 2 deletions php_cs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

return PhpCsFixer\Config::create()
->setRules([
'psr0' => false,
'@PSR2' => true,
'array_syntax' => [
'syntax' => 'short',
Expand All @@ -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,
Expand All @@ -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__)
Expand Down
4 changes: 2 additions & 2 deletions src/Console/TransformDocsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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');
Expand Down
14 changes: 7 additions & 7 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,21 @@ 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 {
$publishPath = base_path('config/opendox.php');
}
$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';
});
}

Expand All @@ -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 () {
Expand Down
4 changes: 4 additions & 0 deletions tests/FullPackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ protected function getStubDirectory(): string

/**
* @param mixed $fileName
*
* @return void
*/
protected function copyStubFile($fileName): void
Expand Down Expand Up @@ -44,6 +45,7 @@ public function itShouldTransformYamlToJson(): void

/**
* @test
*
* @throws \Exception
*/
public function itShouldTestDocsRoute(): void
Expand All @@ -57,6 +59,7 @@ public function itShouldTestDocsRoute(): void

/**
* @test
*
* @throws \Exception
*/
public function itShouldTestRedocRoute(): void
Expand All @@ -70,6 +73,7 @@ public function itShouldTestRedocRoute(): void

/**
* @test
*
* @throws \Exception
*/
public function itShouldTestSwaggerRoute(): void
Expand Down
2 changes: 1 addition & 1 deletion tests/bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require __DIR__.'/../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';

date_default_timezone_set('UTC');

Expand Down

0 comments on commit 1629d71

Please sign in to comment.