From 94cf02640f48823a0e5547727ff4043e4d6599f0 Mon Sep 17 00:00:00 2001 From: VMaarsson Date: Sat, 19 Sep 2026 12:46:12 +0200 Subject: [PATCH] feat(phplint): add php_executable option for parallel-lint configuration --- doc/tasks/phplint.md | 7 +++++++ src/Task/PhpLint.php | 3 +++ test/Unit/Task/PhpLintTest.php | 27 +++++++++++++++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/doc/tasks/phplint.md b/doc/tasks/phplint.md index c3e3b4f74..f29a2758e 100644 --- a/doc/tasks/phplint.md +++ b/doc/tasks/phplint.md @@ -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: []* diff --git a/src/Task/PhpLint.php b/src/Task/PhpLint.php index 108c1953a..8211fe50e 100644 --- a/src/Task/PhpLint.php +++ b/src/Task/PhpLint.php @@ -24,6 +24,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver { $resolver = new OptionsResolver(); $resolver->setDefaults([ + 'php_executable' => null, 'jobs' => null, 'short_open_tag' => false, 'exclude' => [], @@ -31,6 +32,7 @@ public static function getConfigurableOptions(): ConfigOptionsResolver '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'); @@ -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']); diff --git a/test/Unit/Task/PhpLintTest.php b/test/Unit/Task/PhpLintTest.php index 605726f9a..ab528653f 100644 --- a/test/Unit/Task/PhpLintTest.php +++ b/test/Unit/Task/PhpLintTest.php @@ -25,6 +25,7 @@ public static function provideConfigurableOptions(): iterable yield 'defaults' => [ [], [ + 'php_executable' => null, 'jobs' => null, 'short_open_tag' => false, 'exclude' => [], @@ -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