Skip to content

Commit 57fba3a

Browse files
committed
fix ecs
1 parent b2d762b commit 57fba3a

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,6 @@
6363
"monolog/monolog": "^1.3",
6464
"phpunit/phpunit": "^9.0 | ^8.0",
6565
"cache/array-adapter": "^1.0",
66-
"symplify/easy-coding-standard": "^7.2"
66+
"symplify/easy-coding-standard": "^9.0"
6767
}
6868
}

ecs.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Commercetools\Tools\SummaryOnlyOutputFormatter;
6+
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
7+
8+
return static function (ContainerConfigurator $containerConfigurator): void {
9+
$parameters = $containerConfigurator->parameters();
10+
11+
$parameters->set('cache_directory', __DIR__ . '/.ecs_cache');
12+
13+
$parameters->set('paths', [__DIR__ . '/src', __DIR__ . '/test', __DIR__ . '/lib/commercetools-api/src', __DIR__ . '/lib/commercetools-api-tests/test', __DIR__ . '/lib/commercetools-base/src', __DIR__ . '/lib/commercetools-base/test', __DIR__ . '/lib/commercetools-import/src', __DIR__ . '/lib/commercetools-import-tests/test', __DIR__ . '/lib/commercetools-ml/src', __DIR__ . '/lib/commercetools-ml-tests/test']);
14+
15+
$parameters->set('sets', ['psr12']);
16+
17+
$services = $containerConfigurator->services();
18+
19+
$services->set(SummaryOnlyOutputFormatter::class);
20+
};

ecs.yaml

Lines changed: 0 additions & 18 deletions
This file was deleted.

tools/SummaryOnlyOutputFormatter.php

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
use Symplify\EasyCodingStandard\Console\Style\EasyCodingStandardStyle;
99
use Symplify\EasyCodingStandard\Contract\Console\Output\OutputFormatterInterface;
1010
use Symplify\EasyCodingStandard\Error\ErrorAndDiffCollector;
11+
use Symplify\EasyCodingStandard\ValueObject\Error\ErrorAndDiffResult;
1112
use Symplify\PackageBuilder\Console\ShellCode;
1213

1314
final class SummaryOnlyOutputFormatter implements OutputFormatterInterface
@@ -39,13 +40,13 @@ public function __construct(
3940
) {
4041
$this->easyCodingStandardStyle = $easyCodingStandardStyle;
4142
$this->configuration = $configuration;
42-
$this->errorAndDiffCollector = $errorAndDiffCollector;
43+
$errorAndDiffResult = $errorAndDiffCollector;
4344
}
4445

45-
public function report(int $processedFilesCount): int
46+
public function report(ErrorAndDiffResult $errorAndDiffResult, int $processedFilesCount): int
4647
{
47-
if ($this->errorAndDiffCollector->getErrorCount() === 0
48-
&& $this->errorAndDiffCollector->getFileDiffsCount() === 0
48+
if ($errorAndDiffResult->getErrorCount() === 0
49+
&& $errorAndDiffResult->getFileDiffsCount() === 0
4950
) {
5051
if ($processedFilesCount !== 0) {
5152
$this->easyCodingStandardStyle->newLine();
@@ -58,53 +59,53 @@ public function report(int $processedFilesCount): int
5859

5960
$this->easyCodingStandardStyle->newLine();
6061

61-
return $this->configuration->isFixer() ? $this->printAfterFixerStatus() : $this->printNoFixerStatus();
62+
return $this->configuration->isFixer() ? $this->printAfterFixerStatus($errorAndDiffResult) : $this->printNoFixerStatus($errorAndDiffResult);
6263
}
6364

6465
public function getName(): string
6566
{
6667
return self::NAME;
6768
}
6869

69-
private function printAfterFixerStatus(): int
70+
private function printAfterFixerStatus(ErrorAndDiffResult $errorAndDiffResult): int
7071
{
7172
if ($this->configuration->shouldShowErrorTable()) {
72-
$this->easyCodingStandardStyle->printErrors($this->errorAndDiffCollector->getErrors());
73+
$this->easyCodingStandardStyle->printErrors($errorAndDiffResult->getErrors());
7374
}
7475

75-
if ($this->errorAndDiffCollector->getErrorCount() === 0) {
76+
if ($errorAndDiffResult->getErrorCount() === 0) {
7677
$this->easyCodingStandardStyle->success(
7778
sprintf(
7879
'%d error%s successfully fixed and no other found!',
79-
$this->errorAndDiffCollector->getFileDiffsCount(),
80-
$this->errorAndDiffCollector->getFileDiffsCount() === 1 ? '' : 's'
80+
$errorAndDiffResult->getFileDiffsCount(),
81+
$errorAndDiffResult->getFileDiffsCount() === 1 ? '' : 's'
8182
)
8283
);
8384

8485
return ShellCode::SUCCESS;
8586
}
8687

8788
$this->printErrorMessageFromErrorCounts(
88-
$this->errorAndDiffCollector->getErrorCount(),
89-
$this->errorAndDiffCollector->getFileDiffsCount()
89+
$errorAndDiffResult->getErrorCount(),
90+
$errorAndDiffResult->getFileDiffsCount()
9091
);
9192

9293
return ShellCode::ERROR;
9394
}
9495

95-
private function printNoFixerStatus(): int
96+
private function printNoFixerStatus(ErrorAndDiffResult $errorAndDiffResult): int
9697
{
9798
if ($this->configuration->shouldShowErrorTable()) {
98-
$errors = $this->errorAndDiffCollector->getErrors();
99+
$errors = $errorAndDiffResult->getErrors();
99100
if (count($errors) > 0) {
100101
$this->easyCodingStandardStyle->newLine();
101102
$this->easyCodingStandardStyle->printErrors($errors);
102103
}
103104
}
104105

105106
$this->printErrorMessageFromErrorCounts(
106-
$this->errorAndDiffCollector->getErrorCount(),
107-
$this->errorAndDiffCollector->getFileDiffsCount()
107+
$errorAndDiffResult->getErrorCount(),
108+
$errorAndDiffResult->getFileDiffsCount()
108109
);
109110

110111
return ShellCode::ERROR;

0 commit comments

Comments
 (0)