Skip to content

Commit eca0436

Browse files
authored
Merge pull request #1155 from mrmishmash/phpcsParallel
Adds 'parallel' option support to phpcs task.
2 parents b150d47 + 0574524 commit eca0436

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

doc/tasks/phpcs.md

+7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ grumphp:
3131
triggered_by: [php]
3232
exclude: []
3333
show_sniffs_error_path: true
34+
parallel: null
3435
```
3536
3637
**standard**
@@ -136,6 +137,12 @@ A list of rules that should not be checked. Leave this option blank to run all c
136137

137138
Displays the sniff that triggered the error, allowing you to more easily find the specific rules with their namespaces.
138139

140+
**parallel**
141+
142+
*Default: null*
143+
144+
Determines the number of processes that phpcs / phpcbf will use when running. Defaults to a single process.
145+
139146
## Framework presets
140147

141148
### Symfony 2

src/Task/Phpcs.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
4747
'report' => 'full',
4848
'report_width' => null,
4949
'exclude' => [],
50-
'show_sniffs_error_path' => true
50+
'show_sniffs_error_path' => true,
51+
'parallel' => null,
5152
]);
5253

5354
$resolver->addAllowedTypes('standard', ['array', 'null', 'string']);
@@ -64,6 +65,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
6465
$resolver->addAllowedTypes('report_width', ['null', 'int']);
6566
$resolver->addAllowedTypes('exclude', ['array']);
6667
$resolver->addAllowedTypes('show_sniffs_error_path', ['bool']);
68+
$resolver->addAllowedTypes('parallel', ['null', 'int']);
6769

6870
return ConfigOptionsResolver::fromOptionsResolver($resolver);
6971
}
@@ -161,6 +163,7 @@ private function addArgumentsFromConfig(
161163
$arguments->addOptionalCommaSeparatedArgument('--ignore=%s', $config['ignore_patterns']);
162164
$arguments->addOptionalCommaSeparatedArgument('--exclude=%s', $config['exclude']);
163165
$arguments->addOptionalArgument('-s', $config['show_sniffs_error_path']);
166+
$arguments->addOptionalArgument('--parallel=%s', $config['parallel']);
164167

165168
return $arguments;
166169
}

test/Unit/Task/PhpcsTest.php

+17-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ public function provideConfigurableOptions(): iterable
4949
'report' => 'full',
5050
'report_width' => null,
5151
'exclude' => [],
52-
'show_sniffs_error_path' => true
52+
'show_sniffs_error_path' => true,
53+
'parallel' => null,
5354
]
5455
];
5556
}
@@ -357,6 +358,21 @@ public function provideExternalTaskRuns(): iterable
357358
$this->expectFileList('hello.php'.PHP_EOL.'hello2.php'),
358359
]
359360
];
361+
yield 'parallel' => [
362+
[
363+
'parallel' => 4,
364+
],
365+
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
366+
'phpcs',
367+
[
368+
'--extensions=php',
369+
'--report=full',
370+
'-s',
371+
'--parallel=4',
372+
'--report-json',
373+
$this->expectFileList('hello.php'.PHP_EOL.'hello2.php'),
374+
]
375+
];
360376
}
361377

362378
private function expectFileList(string $expectedContents): callable

0 commit comments

Comments
 (0)