Skip to content

Commit

Permalink
Merge pull request #1155 from mrmishmash/phpcsParallel
Browse files Browse the repository at this point in the history
Adds 'parallel' option support to phpcs task.
  • Loading branch information
veewee authored Oct 21, 2024
2 parents b150d47 + 0574524 commit eca0436
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
7 changes: 7 additions & 0 deletions doc/tasks/phpcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ grumphp:
triggered_by: [php]
exclude: []
show_sniffs_error_path: true
parallel: null
```
**standard**
Expand Down Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/Task/Phpcs.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']);
Expand All @@ -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);
}
Expand Down Expand Up @@ -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;
}
Expand Down
18 changes: 17 additions & 1 deletion test/Unit/Task/PhpcsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]
];
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit eca0436

Please sign in to comment.