Skip to content

Commit 844a2fb

Browse files
committed
Added syntax sugar to configure parallel run for PHP CS Fixer
* Added `\Ibexa\CodeStyle\PhpCsFixer\InternalConfigFactory::runInParallel`
1 parent b863ba1 commit 844a2fb

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/lib/PhpCsFixer/InternalConfigFactory.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
use Composer\InstalledVersions;
1212
use Ibexa\CodeStyle\PhpCsFixer\Sets\RuleSetInterface;
1313
use PhpCsFixer\ConfigInterface;
14+
use PhpCsFixer\ParallelAwareConfigInterface;
15+
use PhpCsFixer\Runner\Parallel\ParallelConfigFactory;
1416

1517
/**
1618
* Factory for Config instance that should be used for all internal Ibexa packages.
@@ -24,6 +26,8 @@ final class InternalConfigFactory
2426

2527
private RuleSetInterface $ruleSet;
2628

29+
private bool $runInParallel = false;
30+
2731
/**
2832
* @param array<string, mixed> $rules
2933
*/
@@ -46,6 +50,13 @@ public function getRuleSet(): RuleSetInterface
4650
return $this->ruleSet ??= $this->createRuleSetFromPackage(InstalledVersions::getRootPackage());
4751
}
4852

53+
public function runInParallel(bool $runInParallel = true): self
54+
{
55+
$this->runInParallel = $runInParallel;
56+
57+
return $this;
58+
}
59+
4960
/**
5061
* @param array{name: string, version: string, pretty_version?: string} $package
5162
*/
@@ -78,6 +89,10 @@ public function buildConfig(): ConfigInterface
7889
$this->customRules,
7990
));
8091

92+
if ($this->runInParallel && $config instanceof ParallelAwareConfigInterface) {
93+
$config->setParallelConfig(ParallelConfigFactory::detect());
94+
}
95+
8196
return $config;
8297
}
8398

0 commit comments

Comments
 (0)