From 5fc57b54bdddd7fd1987e3427190fb3ab1ce655f Mon Sep 17 00:00:00 2001 From: lotyp Date: Wed, 29 May 2024 11:39:29 +0300 Subject: [PATCH 1/2] feat: add parallel config --- .php-cs-fixer.dist.php | 1 + docker-compose.yaml | 2 -- src/ConfigBuilder.php | 20 ++++++++++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 4c015eb0..179d5591 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -11,6 +11,7 @@ ->inDir(__DIR__ . '/src') ->inDir(__DIR__ . '/tests') ->addFiles([__FILE__]) + ->useParallelConfig() ->getConfig() ; diff --git a/docker-compose.yaml b/docker-compose.yaml index 623965f8..b46cfec5 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -1,7 +1,5 @@ --- -version: '3.9' - services: app: image: wayofdev/php-dev:8.3-cli-alpine-latest diff --git a/src/ConfigBuilder.php b/src/ConfigBuilder.php index 54ab11ec..af398df3 100644 --- a/src/ConfigBuilder.php +++ b/src/ConfigBuilder.php @@ -8,6 +8,8 @@ use PhpCsFixer\Config; use PhpCsFixer\ConfigInterface; use PhpCsFixer\Finder; +use PhpCsFixer\Runner\Parallel\ParallelConfig; +use PhpCsFixer\Runner\Parallel\ParallelConfigFactory; use function call_user_func_array; use function get_class; @@ -86,6 +88,24 @@ public function getConfig(): ConfigInterface return $this->config->setRules($this->ruleSet->rules()); } + /** + * Wrapper method to set parallel config. + * + * @param positive-int|null $maxProcesses + * @param positive-int|null $filesPerProcess + * @param positive-int|null $processTimeout + */ + public function useParallelConfig(?int $maxProcesses = null, ?int $filesPerProcess = null, ?int $processTimeout = null): self + { + if ($maxProcesses !== null && $filesPerProcess !== null && $processTimeout !== null) { + $this->config->setParallelConfig(new ParallelConfig($maxProcesses, $filesPerProcess, $processTimeout)); + } else { + $this->config->setParallelConfig(ParallelConfigFactory::detect()); + } + + return $this; + } + private function getFinder(): Finder { return $this->config->getFinder(); From 5ac2aa736d494d2803a1bf854b64b46d6fcf2549 Mon Sep 17 00:00:00 2001 From: lotyp Date: Wed, 29 May 2024 11:39:56 +0300 Subject: [PATCH 2/2] deps: update composer --- composer.lock | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/composer.lock b/composer.lock index 40ae3d45..4b7cbb1e 100644 --- a/composer.lock +++ b/composer.lock @@ -398,16 +398,16 @@ }, { "name": "friendsofphp/php-cs-fixer", - "version": "v3.57.2", + "version": "v3.58.0", "source": { "type": "git", "url": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer.git", - "reference": "22f7f3145606df92b02fb1bd22c30abfce956d3c" + "reference": "55d3483c80c09f91d876aa4e2971ce349d07310c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/22f7f3145606df92b02fb1bd22c30abfce956d3c", - "reference": "22f7f3145606df92b02fb1bd22c30abfce956d3c", + "url": "https://api.github.com/repos/PHP-CS-Fixer/PHP-CS-Fixer/zipball/55d3483c80c09f91d876aa4e2971ce349d07310c", + "reference": "55d3483c80c09f91d876aa4e2971ce349d07310c", "shasum": "" }, "require": { @@ -486,7 +486,7 @@ ], "support": { "issues": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/issues", - "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.57.2" + "source": "https://github.com/PHP-CS-Fixer/PHP-CS-Fixer/tree/v3.58.0" }, "funding": [ { @@ -494,7 +494,7 @@ "type": "github" } ], - "time": "2024-05-20T20:41:57+00:00" + "time": "2024-05-28T16:55:30+00:00" }, { "name": "psr/container", @@ -3641,12 +3641,12 @@ "version": "v5.2.13", "source": { "type": "git", - "url": "https://github.com/justinrainbow/json-schema.git", + "url": "https://github.com/jsonrainbow/json-schema.git", "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/justinrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", + "url": "https://api.github.com/repos/jsonrainbow/json-schema/zipball/fbbe7e5d79f618997bc3332a6f49246036c45793", "reference": "fbbe7e5d79f618997bc3332a6f49246036c45793", "shasum": "" }, @@ -3701,8 +3701,8 @@ "schema" ], "support": { - "issues": "https://github.com/justinrainbow/json-schema/issues", - "source": "https://github.com/justinrainbow/json-schema/tree/v5.2.13" + "issues": "https://github.com/jsonrainbow/json-schema/issues", + "source": "https://github.com/jsonrainbow/json-schema/tree/v5.2.13" }, "time": "2023-09-26T02:20:38+00:00" }, @@ -4554,16 +4554,16 @@ }, { "name": "phpdocumentor/reflection-docblock", - "version": "5.4.0", + "version": "5.4.1", "source": { "type": "git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "298d2febfe79d03fe714eb871d5538da55205b1a" + "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/298d2febfe79d03fe714eb871d5538da55205b1a", - "reference": "298d2febfe79d03fe714eb871d5538da55205b1a", + "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", + "reference": "9d07b3f7fdcf5efec5d1609cba3c19c5ea2bdc9c", "shasum": "" }, "require": { @@ -4612,9 +4612,9 @@ "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "support": { "issues": "https://github.com/phpDocumentor/ReflectionDocBlock/issues", - "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.0" + "source": "https://github.com/phpDocumentor/ReflectionDocBlock/tree/5.4.1" }, - "time": "2024-04-09T21:13:58+00:00" + "time": "2024-05-21T05:55:05+00:00" }, { "name": "phpdocumentor/type-resolver",