From 21a495ad8b4665883a9a4228e8a50d867baecc47 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 14 Jun 2018 10:48:48 +0200 Subject: [PATCH 1/4] composer: allow Symfony 3.4 + update other deps --- composer.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/composer.json b/composer.json index a06e194c..252ee5a1 100644 --- a/composer.json +++ b/composer.json @@ -11,18 +11,18 @@ ], "require": { "php": "^7.1.3", - "symfony/process": "^4.0", - "symfony/event-dispatcher": "^4.0" + "symfony/process": "^3.4|^4.0", + "symfony/event-dispatcher": "^3.4|^4.0" }, "require-dev": { - "phpunit/phpunit": "^7.0", - "symfony/filesystem": "^4.0", + "phpunit/phpunit": "^7.2", + "symfony/filesystem": "^3.4|^4.0", "psr/log": "1.0", - "symplify/easy-coding-standard": "^3.0", - "slam/php-cs-fixer-extensions": "^1.10", - "nette/utils": "^2.4", + "symplify/easy-coding-standard": "^4.4", + "slam/php-cs-fixer-extensions": "^1.16", + "nette/utils": "^2.5", "phpstan/phpstan": "^0.9", - "symplify/changelog-linker": "^3.0" + "symplify/changelog-linker": "^4.4" }, "autoload": { "psr-4": { From 6a25dfd0b5c9a20abb23933460a23851c050899e Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 14 Jun 2018 10:53:05 +0200 Subject: [PATCH 2/4] update ECS config --- easy-coding-standard.neon | 30 ------------------------------ ecs.yml | 23 +++++++++++++++++++++++ 2 files changed, 23 insertions(+), 30 deletions(-) delete mode 100644 easy-coding-standard.neon create mode 100644 ecs.yml diff --git a/easy-coding-standard.neon b/easy-coding-standard.neon deleted file mode 100644 index 4ff92407..00000000 --- a/easy-coding-standard.neon +++ /dev/null @@ -1,30 +0,0 @@ -includes: - - vendor/symplify/easy-coding-standard/config/psr2.neon - - vendor/symplify/easy-coding-standard/config/php71.neon - - vendor/symplify/easy-coding-standard/config/common.neon - - vendor/symplify/easy-coding-standard/config/clean-code.neon - - vendor/symplify/easy-coding-standard/config/symplify.neon - -checkers: - # Metrics - PHP_CodeSniffer\Standards\Generic\Sniffs\Files\LineLengthSniff: - absoluteLineLimit: 120 - PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\CyclomaticComplexitySniff: - absoluteComplexity: 6 - PHP_CodeSniffer\Standards\Generic\Sniffs\Metrics\NestingLevelSniff: - absoluteNestingLevel: 4 - - # Class should be Final or Abstract - - SlamCsFixer\FinalInternalClassFixer -parameters: - exclude_checkers: - - PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff - - Symplify\CodingStandard\Sniffs\DependencyInjection\NoClassInstantiationSniff - - skip: - SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff: - - tests/TestLogger.php - - SlamCsFixer\FinalInternalClassFixer: - # class with children - - src/Event/GitEvent.php diff --git a/ecs.yml b/ecs.yml new file mode 100644 index 00000000..bcf15ec0 --- /dev/null +++ b/ecs.yml @@ -0,0 +1,23 @@ +imports: + - { resource: 'vendor/symplify/easy-coding-standard/config/psr2.yml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/php71.yml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/common.yml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/clean-code.yml' } + - { resource: 'vendor/symplify/easy-coding-standard/config/symplify.yml' } + +services: + # Class should be Final or Abstract + SlamCsFixer\FinalInternalClassFixer: ~ + +parameters: + exclude_checkers: + - 'PHP_CodeSniffer\Standards\Generic\Sniffs\CodeAnalysis\AssignmentInConditionSniff' + - 'Symplify\CodingStandard\Sniffs\DependencyInjection\NoClassInstantiationSniff' + + skip: + SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff: + - 'tests/TestLogger.php' + + SlamCsFixer\FinalInternalClassFixer: + # class with children + - 'src/Event/GitEvent.php' From 4b564e3e056a3bc6e7a099671a9281405f82b73c Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 14 Jun 2018 10:53:16 +0200 Subject: [PATCH 3/4] fix cs --- src/GitCommand.php | 6 +----- tests/GitWorkingCopyTest.php | 8 ++++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/src/GitCommand.php b/src/GitCommand.php index 9c2758e6..ffe24236 100644 --- a/src/GitCommand.php +++ b/src/GitCommand.php @@ -183,11 +183,7 @@ public function getCommandLine() return $this->getCommand(); } - $command = array_merge( - [$this->getCommand()], - $this->buildOptions(), - $this->args - ); + $command = array_merge([$this->getCommand()], $this->buildOptions(), $this->args); return array_filter($command); } diff --git a/tests/GitWorkingCopyTest.php b/tests/GitWorkingCopyTest.php index 9f05b7a3..b6c016b2 100644 --- a/tests/GitWorkingCopyTest.php +++ b/tests/GitWorkingCopyTest.php @@ -18,7 +18,7 @@ final class GitWorkingCopyTest extends AbstractGitWrapperTestCase /** * Creates and initializes the local repository used for testing. */ - public function setUp(): void + protected function setUp(): void { parent::setUp(); @@ -403,9 +403,9 @@ public function testCommitWithAuthor(): void $git->add('commit.txt'); $git->commit([ - 'm' => 'Committed testing branch.', - 'a' => true, - 'author' => 'test ', + 'm' => 'Committed testing branch.', + 'a' => true, + 'author' => 'test ', ]); $output = $git->log(); From 8b613b5aa3454e8b54ee0211791a38a726975d41 Mon Sep 17 00:00:00 2001 From: Tomas Votruba Date: Thu, 14 Jun 2018 10:55:33 +0200 Subject: [PATCH 4/4] ecs: ignore unfixable errors --- composer.json | 6 +++--- ecs.yml | 10 ++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 252ee5a1..e6201be9 100644 --- a/composer.json +++ b/composer.json @@ -11,12 +11,12 @@ ], "require": { "php": "^7.1.3", - "symfony/process": "^3.4|^4.0", - "symfony/event-dispatcher": "^3.4|^4.0" + "symfony/process": "^4.0", + "symfony/event-dispatcher": "^4.0" }, "require-dev": { "phpunit/phpunit": "^7.2", - "symfony/filesystem": "^3.4|^4.0", + "symfony/filesystem": "^4.0", "psr/log": "1.0", "symplify/easy-coding-standard": "^4.4", "slam/php-cs-fixer-extensions": "^1.16", diff --git a/ecs.yml b/ecs.yml index bcf15ec0..1321cb4c 100644 --- a/ecs.yml +++ b/ecs.yml @@ -18,6 +18,16 @@ parameters: SlevomatCodingStandard\Sniffs\TypeHints\TypeHintDeclarationSniff: - 'tests/TestLogger.php' + Symplify\CodingStandard\Sniffs\CleanCode\ForbiddenStaticFunctionSniff: + # helper method + - 'src/GitWrapper.php' + # parent interface → nothing we can do about this + - 'src/Event/GitLoggerListener.php' + SlamCsFixer\FinalInternalClassFixer: # class with children - 'src/Event/GitEvent.php' + + Symplify\CodingStandard\Sniffs\CleanCode\ForbiddenReferenceSniff: + # native PHP api → nothing we can do about this + - 'tests/StreamSuppressFilter.php'