diff --git a/composer.json b/composer.json index 748ab542..00d9b0e1 100644 --- a/composer.json +++ b/composer.json @@ -78,7 +78,6 @@ "sebastian/phpcpd": "Lets GrumPHP find duplicated code.", "squizlabs/php_codesniffer": "Lets GrumPHP sniff on your code.", "sstalle/php7cc": "Lets GrumPHP check PHP 5.3 - 5.6 code compatibility with PHP 7.", - "symfony/console": "Lets GrumPHP run Symfony Console commands.", "symfony/phpunit-bridge": "Lets GrumPHP run your unit tests with the phpunit-bridge of Symfony.", "symplify/easy-coding-standard": "Lets GrumPHP check coding standard.", "vimeo/psalm": "Lets GrumPHP discover errors in your code without running it.", diff --git a/doc/tasks/symfony_console.md b/doc/tasks/symfony_console.md index 3d3210df..525fdc3f 100644 --- a/doc/tasks/symfony_console.md +++ b/doc/tasks/symfony_console.md @@ -2,13 +2,9 @@ Run a symfony console command. -## Composer +## Requirements -Requires the Symfony Console component: [Console Component](https://symfony.com/components/Console) - -```bash -composer require symfony/console -``` +This task requires a Symfony application with console component. ## Config diff --git a/src/Task/SymfonyConsole.php b/src/Task/SymfonyConsole.php index 47c29013..34726945 100644 --- a/src/Task/SymfonyConsole.php +++ b/src/Task/SymfonyConsole.php @@ -12,7 +12,6 @@ use GrumPHP\Task\Context\GitPreCommitContext; use GrumPHP\Task\Context\RunContext; use Symfony\Component\OptionsResolver\OptionsResolver; -use Symfony\Component\Process\PhpExecutableFinder; /** @extends AbstractExternalTask */ class SymfonyConsole extends AbstractExternalTask @@ -65,12 +64,7 @@ public function run(ContextInterface $context): TaskResultInterface return TaskResult::createSkipped($this, $context); } - $php = (new PhpExecutableFinder())->find(); - if (false === $php) { - return TaskResult::createFailed($this, $context, 'Unable to locate the PHP executable.'); - } - - $arguments = $this->processBuilder->createArgumentsForCommand($php); + $arguments = $this->processBuilder->createArgumentsForCommand('php'); $arguments->add($config['bin']); $arguments->addArgumentArray('%s', $config['command']); diff --git a/test/Unit/Task/SymfonyConsoleTest.php b/test/Unit/Task/SymfonyConsoleTest.php index 82b361d0..2306db5b 100644 --- a/test/Unit/Task/SymfonyConsoleTest.php +++ b/test/Unit/Task/SymfonyConsoleTest.php @@ -9,17 +9,9 @@ use GrumPHP\Task\SymfonyConsole; use GrumPHP\Task\TaskInterface; use GrumPHP\Test\Task\AbstractExternalTaskTestCase; -use Symfony\Component\Process\PhpExecutableFinder; final class SymfonyConsoleTest extends AbstractExternalTaskTestCase { - private static string|false $php; - - private static function php(): string|false - { - return self::$php ??= (new PhpExecutableFinder())->find(); - } - protected function provideTask(): TaskInterface { return new SymfonyConsole( @@ -91,7 +83,7 @@ public function provideFailsOnStuff(): iterable $this->mockContext(RunContext::class, ['hello.php', 'hello2.php']), function() { $process = $this->mockProcess(1); - $this->mockProcessBuilder(self::php(), $process); + $this->mockProcessBuilder('php', $process); $this->formatter->format($process)->willReturn('nope'); }, 'nope' @@ -106,7 +98,7 @@ public function providePassesOnStuff(): iterable ], $this->mockContext(RunContext::class, ['hello.php', 'hello2.php']), function() { - $this->mockProcessBuilder(self::php(), $this->mockProcess()); + $this->mockProcessBuilder('php', $this->mockProcess()); } ]; @@ -117,7 +109,7 @@ function() { ], $this->mockContext(RunContext::class, ['non-related.log']), function() { - $this->mockProcessBuilder(self::php(), $this->mockProcess()); + $this->mockProcessBuilder('php', $this->mockProcess()); } ]; } @@ -170,7 +162,7 @@ public function provideExternalTaskRuns(): iterable 'command' => ['lint:container'] ], $this->mockContext(RunContext::class, ['hello.php', 'hello2.php']), - self::php(), + 'php', [ './bin/console', 'lint:container', @@ -187,7 +179,7 @@ public function provideExternalTaskRuns(): iterable ] ], $this->mockContext(RunContext::class, ['hello.php', 'hello2.php']), - self::php(), + 'php', [ './bin/console', 'task:run',