Skip to content

Commit

Permalink
Update composer, docs, remove php excutable finder
Browse files Browse the repository at this point in the history
  • Loading branch information
bortefi committed Jun 14, 2024
1 parent 250ca75 commit 3900ffb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 27 deletions.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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.",
Expand Down
8 changes: 2 additions & 6 deletions doc/tasks/symfony_console.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 1 addition & 7 deletions src/Task/SymfonyConsole.php
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProcessFormatterInterface> */
class SymfonyConsole extends AbstractExternalTask
Expand Down Expand Up @@ -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']);

Expand Down
18 changes: 5 additions & 13 deletions test/Unit/Task/SymfonyConsoleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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'
Expand All @@ -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());
}
];

Expand All @@ -117,7 +109,7 @@ function() {
],
$this->mockContext(RunContext::class, ['non-related.log']),
function() {
$this->mockProcessBuilder(self::php(), $this->mockProcess());
$this->mockProcessBuilder('php', $this->mockProcess());
}
];
}
Expand Down Expand Up @@ -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',
Expand All @@ -187,7 +179,7 @@ public function provideExternalTaskRuns(): iterable
]
],
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
self::php(),
'php',
[
'./bin/console',
'task:run',
Expand Down

0 comments on commit 3900ffb

Please sign in to comment.