From 618360583e2dc6d2e2eafb8b42ba5164b7225fea Mon Sep 17 00:00:00 2001 From: Marcin Tracz Date: Mon, 12 Apr 2021 11:10:46 +0200 Subject: [PATCH] #15 - docker improvement, default rules set improvement (#16) * Added default value for CURRENT_UID_AND_GID in docker, added .env.example, improved readme.md, bump docker image to 8.0.3.1 * Half fixed BinaryOperatorSpacesFixer, Added PhpdocLineSpanFixer * ecs fix * tests fix * revert docker-compose user value * pr fixes * Added PhpdocLineSpanFixer --- .env.example | 1 + .gitignore | 1 + composer.json | 2 +- docker-compose.yml | 2 +- readme.md | 26 +++++++++++++++++++ .../Defaults/CommonAdditionalRules.php | 5 ++++ tests/AdditionalRulesConfigurationTest.php | 17 ++++++++++++ 7 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 .env.example diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..bac1b40 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +CURRENT_UID=1000 diff --git a/.gitignore b/.gitignore index 6f21493..7224874 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ /vendor composer.lock +.env diff --git a/composer.json b/composer.json index 4ee5565..c5398ca 100644 --- a/composer.json +++ b/composer.json @@ -25,7 +25,7 @@ "scripts": { "ecs": "./vendor/bin/ecs check", "ecsf": "./vendor/bin/ecs check --fix", - "test": "./vendor/bin/phpunit tests" + "test": "./vendor/bin/phpunit tests --colors always" }, "require-dev": { "phpunit/phpunit": "^9.5" diff --git a/docker-compose.yml b/docker-compose.yml index bc67bd6..8eabc01 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.7" services: php: - image: ghcr.io/blumilksoftware/php:8.0.2.1 + image: ghcr.io/blumilksoftware/php:8.0.3.1 container_name: blumilk-codestyle-php working_dir: /application user: ${CURRENT_UID} diff --git a/readme.md b/readme.md index 5043d28..11ba22c 100644 --- a/readme.md +++ b/readme.md @@ -69,3 +69,29 @@ Then run: ```shell composer ecs ``` + +# Contributing + +### Requirements +- docker +- docker-compose + +### installation + +```shell +cp .env.example .env +# adjust '.env' file +docker-compose up -d +docker-compose exec php composer install +``` +### shell +```shell +docker-compose exec php ash +``` + +### scripts +```shell +docker-compose exec php composer ecs +docker-compose exec php composer ecsf +docker-compose exec php composer test +``` \ No newline at end of file diff --git a/src/Configuration/Defaults/CommonAdditionalRules.php b/src/Configuration/Defaults/CommonAdditionalRules.php index 4179cdf..f68b4d0 100644 --- a/src/Configuration/Defaults/CommonAdditionalRules.php +++ b/src/Configuration/Defaults/CommonAdditionalRules.php @@ -13,6 +13,7 @@ use PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer; use PhpCsFixer\Fixer\Import\FullyQualifiedStrictTypesFixer; use PhpCsFixer\Fixer\Import\OrderedImportsFixer; +use PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer; use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer; class CommonAdditionalRules extends Rules implements AdditionalRules @@ -29,5 +30,9 @@ class CommonAdditionalRules extends Rules implements AdditionalRules FullyQualifiedStrictTypesFixer::class => null, OrderedImportsFixer::class => null, BinaryOperatorSpacesFixer::class => null, + PhpdocLineSpanFixer::class => [ + "const" => "single", + "property" => "single", + ], ]; } diff --git a/tests/AdditionalRulesConfigurationTest.php b/tests/AdditionalRulesConfigurationTest.php index 7d01bbd..d0bbd20 100644 --- a/tests/AdditionalRulesConfigurationTest.php +++ b/tests/AdditionalRulesConfigurationTest.php @@ -14,6 +14,7 @@ use PhpCsFixer\Fixer\FunctionNotation\VoidReturnFixer; use PhpCsFixer\Fixer\Import\FullyQualifiedStrictTypesFixer; use PhpCsFixer\Fixer\Import\OrderedImportsFixer; +use PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer; use PhpCsFixer\Fixer\Strict\DeclareStrictTypesFixer; use PhpCsFixer\Fixer\StringNotation\HeredocToNowdocFixer; use PHPUnit\Framework\TestCase; @@ -38,6 +39,10 @@ public function testAdditionalRulesConfiguration(): void FullyQualifiedStrictTypesFixer::class => null, OrderedImportsFixer::class => null, BinaryOperatorSpacesFixer::class => null, + PhpdocLineSpanFixer::class => [ + "const" => "single", + "property" => "single", + ], ], $config->options()["rules"] ); @@ -66,6 +71,10 @@ public function testFilteringAdditionalRulesConfiguration(): void FullyQualifiedStrictTypesFixer::class => null, OrderedImportsFixer::class => null, BinaryOperatorSpacesFixer::class => null, + PhpdocLineSpanFixer::class => [ + "const" => "single", + "property" => "single", + ], ], $config->options()["rules"] ); @@ -91,6 +100,10 @@ public function testExtendingAdditionalRulesConfiguration(): void FullyQualifiedStrictTypesFixer::class => null, OrderedImportsFixer::class => null, BinaryOperatorSpacesFixer::class => null, + PhpdocLineSpanFixer::class => [ + "const" => "single", + "property" => "single", + ], HeredocToNowdocFixer::class => null, ], $config->options()["rules"] @@ -121,6 +134,10 @@ public function testExtendingWithOptionsAdditionalRulesConfiguration(): void FullyQualifiedStrictTypesFixer::class => null, OrderedImportsFixer::class => null, BinaryOperatorSpacesFixer::class => null, + PhpdocLineSpanFixer::class => [ + "const" => "single", + "property" => "single", + ], NoMixedEchoPrintFixer::class => [ "use" => "echo", ],