Skip to content
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
7 changes: 7 additions & 0 deletions doc/tasks/phplint.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ composer require --dev php-parallel-lint/php-parallel-lint
grumphp:
tasks:
phplint:
php_executable: null
exclude: []
jobs: ~
short_open_tag: false
ignore_patterns: []
triggered_by: ['php', 'phtml', 'php3', 'php4', 'php5']
```
**php_executable**

*Default: null*

Specifies the PHP executable passed to parallel-lint via the -p option.

**exclude**

*Default: []*
Expand Down
3 changes: 3 additions & 0 deletions src/Task/PhpLint.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,15 @@ public static function getConfigurableOptions(): ConfigOptionsResolver
{
$resolver = new OptionsResolver();
$resolver->setDefaults([
'php_executable' => null,
'jobs' => null,
'short_open_tag' => false,
'exclude' => [],
'ignore_patterns' => [],
'triggered_by' => ['php', 'phtml', 'php3', 'php4', 'php5'],
]);

$resolver->setAllowedTypes('php_executable', ['string', 'null']);
$resolver->setAllowedTypes('jobs', ['int', 'null']);
$resolver->setAllowedTypes('short_open_tag', 'bool');
$resolver->setAllowedTypes('exclude', 'array');
Expand Down Expand Up @@ -60,6 +62,7 @@ public function run(ContextInterface $context): TaskResultInterface

$arguments = $this->processBuilder->createArgumentsForCommand('parallel-lint');
$arguments->add('--no-colors');
$arguments->addOptionalArgumentWithSeparatedValue('-p', $config['php_executable']);
$arguments->addOptionalArgumentWithSeparatedValue('-j', $config['jobs']);
$arguments->addOptionalArgument('--short', $config['short_open_tag']);
$arguments->addArgumentArrayWithSeparatedValue('--exclude', $config['exclude']);
Expand Down
27 changes: 27 additions & 0 deletions test/Unit/Task/PhpLintTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public static function provideConfigurableOptions(): iterable
yield 'defaults' => [
[],
[
'php_executable' => null,
'jobs' => null,
'short_open_tag' => false,
'exclude' => [],
Expand Down Expand Up @@ -109,6 +110,32 @@ public static function provideExternalTaskRuns(): iterable
],
self::mockProcessWithStdIn(0)
];
yield 'php_executable_null' => [
[
'php_executable' => null,
],
self::mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'parallel-lint',
[
'--no-colors',
'--stdin',
],
self::mockProcessWithStdIn(0)
];
yield 'php_executable' => [
[
'php_executable' => '/usr/bin/php',
],
self::mockContext(RunContext::class, ['hello.php', 'hello2.php']),
'parallel-lint',
[
'--no-colors',
'-p',
'/usr/bin/php',
'--stdin',
],
self::mockProcessWithStdIn(0)
];
yield 'jobs' => [
[
'jobs' => 10
Expand Down
Loading