Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add parallel config #287

Merged
merged 2 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
->inDir(__DIR__ . '/src')
->inDir(__DIR__ . '/tests')
->addFiles([__FILE__])
->useParallelConfig()
->getConfig()
;

Expand Down
32 changes: 16 additions & 16 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
---

version: '3.9'

services:
app:
image: wayofdev/php-dev:8.3-cli-alpine-latest
Expand Down
20 changes: 20 additions & 0 deletions src/ConfigBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -86,6 +88,24 @@
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

Check warning on line 98 in src/ConfigBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/ConfigBuilder.php#L98

Added line #L98 was not covered by tests
{
if ($maxProcesses !== null && $filesPerProcess !== null && $processTimeout !== null) {
$this->config->setParallelConfig(new ParallelConfig($maxProcesses, $filesPerProcess, $processTimeout));

Check warning on line 101 in src/ConfigBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/ConfigBuilder.php#L100-L101

Added lines #L100 - L101 were not covered by tests
} else {
$this->config->setParallelConfig(ParallelConfigFactory::detect());

Check warning on line 103 in src/ConfigBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/ConfigBuilder.php#L103

Added line #L103 was not covered by tests
}

return $this;

Check warning on line 106 in src/ConfigBuilder.php

View check run for this annotation

Codecov / codecov/patch

src/ConfigBuilder.php#L106

Added line #L106 was not covered by tests
}

private function getFinder(): Finder
{
return $this->config->getFinder();
Expand Down
Loading