From c59d4faee54dc5c059f06e78f05450f207942590 Mon Sep 17 00:00:00 2001 From: Artem Date: Fri, 8 Apr 2022 19:18:17 +0300 Subject: [PATCH] Update dependencies (#181) * update dependencies, fix tests * fix tests * fix tests * fix tests * fix tests Co-authored-by: Artjoms Suharevs --- .github/workflows/tests.yml | 6 ++--- composer.json | 6 ++--- ecs.php | 30 +++++++--------------- src/GitElephant/Objects/Diff/DiffChunk.php | 6 +++-- src/GitElephant/Objects/LogRange.php | 2 +- tests/GitElephant/TestCase.php | 2 +- 6 files changed, 20 insertions(+), 32 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 117b529e..8d224388 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -12,18 +12,16 @@ jobs: strategy: matrix: php: - - "7.3" - "7.4" - "8.0" symfony: - - 3.* - - 4.* - 5.* + - 6.* dependency-version: # - prefer-lowest - prefer-stable exclude: - - {php: "8.0", symfony: "3.*"} + - {php: "7.4", symfony: "6.*"} name: PHP ${{ matrix.php }} - S ${{ matrix.symfony }} - ${{ matrix.dependency-version }} - tests steps: diff --git a/composer.json b/composer.json index 4441f677..1f62a159 100644 --- a/composer.json +++ b/composer.json @@ -19,9 +19,9 @@ ], "require": { "php": ">=7.2.0", - "symfony/process": "~3.4|~4.0|~5.0", - "symfony/filesystem": "~3.4|~4.0|~5.0", - "symfony/finder": "~3.4|~4.0|~5.0", + "symfony/process": ">=3.4", + "symfony/filesystem": ">=3.4", + "symfony/finder": ">=3.4", "phpcollection/phpcollection": "~0.4|~0.5" }, "require-dev": { diff --git a/ecs.php b/ecs.php index ab39a780..7646e81b 100644 --- a/ecs.php +++ b/ecs.php @@ -2,30 +2,18 @@ use PhpCsFixer\Fixer\ArrayNotation\ArraySyntaxFixer; use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator; -use Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer; -use Symplify\EasyCodingStandard\ValueObject\Option; use Symplify\EasyCodingStandard\ValueObject\Set\SetList; +use Symplify\EasyCodingStandard\ValueObject\Option; return static function (ContainerConfigurator $containerConfigurator): void { - $services = $containerConfigurator->services(); - // $services->set(ArraySyntaxFixer::class)->call('configure', [ - // 'syntax' => 'short' - // ]); - - // $services->set(LineLengthFixer::class)->call('configure', [ - // "max_line_length" => 100, - // "break_long_lines" => true, # default: true - // "inline_short_lines" => false # default: true - // ]); - $parameters = $containerConfigurator->parameters(); - - $parameters->set(Option::SETS, [ - SetList::CLEAN_CODE, - SetList::PSR_12 - ]); - $parameters->set(Option::PATHS, [__DIR__ . '/src', __DIR__ . '/tests']); - $parameters->set(Option::SKIP, ['Unused variable $deleted.' => ['src/GitElephant/Objects/Diff/DiffChunk.php'], 'Unused variable $new.' => ['src/GitElephant/Objects/Diff/DiffChunk.php']]); -}; + // A. full sets + $containerConfigurator->import(SetList::PSR_12); + + // B. standalone rule + $services = $containerConfigurator->services(); + $services->set(ArraySyntaxFixer::class) + ->call('configure', [[ 'syntax' => 'short', ]]); +}; \ No newline at end of file diff --git a/src/GitElephant/Objects/Diff/DiffChunk.php b/src/GitElephant/Objects/Diff/DiffChunk.php index 39706d3a..7f197206 100644 --- a/src/GitElephant/Objects/Diff/DiffChunk.php +++ b/src/GitElephant/Objects/Diff/DiffChunk.php @@ -136,7 +136,8 @@ private function getLinesNumbers(string $line): void $this->originStartLine = $matches[1]; $this->originEndLine = $matches[1]; } else { - [$this->originStartLine, $this->originEndLine] = explode(',', $matches[1]); + $this->originStartLine = (int) explode(',', $matches[1])[0]; + $this->originEndLine = (int) explode(',', $matches[1])[1]; } if (!strpos($matches[2], ',')) { @@ -144,7 +145,8 @@ private function getLinesNumbers(string $line): void $this->destStartLine = $matches[2]; $this->destEndLine = $matches[2]; } else { - [$this->destStartLine, $this->destEndLine] = explode(',', $matches[2]); + $this->destStartLine = (int) explode(',', $matches[2])[0]; + $this->destEndLine = (int) explode(',', $matches[2])[1]; } } diff --git a/src/GitElephant/Objects/LogRange.php b/src/GitElephant/Objects/LogRange.php index 7678a5dc..36f64c14 100644 --- a/src/GitElephant/Objects/LogRange.php +++ b/src/GitElephant/Objects/LogRange.php @@ -128,7 +128,7 @@ private function parseOutputLines(array $outputLines): void $commitLines[] = $line; } - if (null !== $commitLines && count($commitLines) > 0) { + if (is_array($commitLines) && count($commitLines) !== 0) { $this->rangeCommits[] = Commit::createFromOutputLines($this->getRepository(), $commitLines); } } diff --git a/tests/GitElephant/TestCase.php b/tests/GitElephant/TestCase.php index 75ca0e9b..8632d63b 100644 --- a/tests/GitElephant/TestCase.php +++ b/tests/GitElephant/TestCase.php @@ -115,7 +115,7 @@ protected function tearDown(): void array_map(function (Repository $repo) use ($fs) { $fs->remove($repo->getPath()); }, $this->repository); - } else { + } elseif ($this->path) { $fs->remove($this->path); } m::close();