diff --git a/doc/tasks/phpcs.md b/doc/tasks/phpcs.md index 3ffc2cf8..a2b4dc0c 100644 --- a/doc/tasks/phpcs.md +++ b/doc/tasks/phpcs.md @@ -31,6 +31,7 @@ grumphp: triggered_by: [php] exclude: [] show_sniffs_error_path: true + parallel: null ``` **standard** @@ -136,6 +137,12 @@ A list of rules that should not be checked. Leave this option blank to run all c Displays the sniff that triggered the error, allowing you to more easily find the specific rules with their namespaces. +**parallel** + +*Default: null* + +Determines the number of processes that phpcs / phpcbf will use when running. Defaults to a single process. + ## Framework presets ### Symfony 2 diff --git a/src/Task/Phpcs.php b/src/Task/Phpcs.php index c16320b3..8d3c1812 100644 --- a/src/Task/Phpcs.php +++ b/src/Task/Phpcs.php @@ -47,7 +47,8 @@ public static function getConfigurableOptions(): ConfigOptionsResolver 'report' => 'full', 'report_width' => null, 'exclude' => [], - 'show_sniffs_error_path' => true + 'show_sniffs_error_path' => true, + 'parallel' => null, ]); $resolver->addAllowedTypes('standard', ['array', 'null', 'string']); @@ -64,6 +65,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver $resolver->addAllowedTypes('report_width', ['null', 'int']); $resolver->addAllowedTypes('exclude', ['array']); $resolver->addAllowedTypes('show_sniffs_error_path', ['bool']); + $resolver->addAllowedTypes('parallel', ['null', 'int']); return ConfigOptionsResolver::fromOptionsResolver($resolver); } @@ -161,6 +163,7 @@ private function addArgumentsFromConfig( $arguments->addOptionalCommaSeparatedArgument('--ignore=%s', $config['ignore_patterns']); $arguments->addOptionalCommaSeparatedArgument('--exclude=%s', $config['exclude']); $arguments->addOptionalArgument('-s', $config['show_sniffs_error_path']); + $arguments->addOptionalArgument('--parallel=%s', $config['parallel']); return $arguments; } diff --git a/test/Unit/Task/PhpcsTest.php b/test/Unit/Task/PhpcsTest.php index 45c36cb1..b2e6b3f2 100644 --- a/test/Unit/Task/PhpcsTest.php +++ b/test/Unit/Task/PhpcsTest.php @@ -49,7 +49,8 @@ public function provideConfigurableOptions(): iterable 'report' => 'full', 'report_width' => null, 'exclude' => [], - 'show_sniffs_error_path' => true + 'show_sniffs_error_path' => true, + 'parallel' => null, ] ]; } @@ -357,6 +358,21 @@ public function provideExternalTaskRuns(): iterable $this->expectFileList('hello.php'.PHP_EOL.'hello2.php'), ] ]; + yield 'parallel' => [ + [ + 'parallel' => 4, + ], + $this->mockContext(RunContext::class, ['hello.php', 'hello2.php']), + 'phpcs', + [ + '--extensions=php', + '--report=full', + '-s', + '--parallel=4', + '--report-json', + $this->expectFileList('hello.php'.PHP_EOL.'hello2.php'), + ] + ]; } private function expectFileList(string $expectedContents): callable