1111use Composer \InstalledVersions ;
1212use Ibexa \CodeStyle \PhpCsFixer \Sets \RuleSetInterface ;
1313use 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,11 +89,15 @@ 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
84- public static function build (): ConfigInterface
99+ public static function build (bool $ runInParallel = false ): ConfigInterface
85100 {
86- return (new self ())->buildConfig ();
101+ return (new self ())->runInParallel ( $ runInParallel )-> buildConfig ();
87102 }
88103}
0 commit comments