Skip to content

Commit 3900ffb

Browse files
committed
Update composer, docs, remove php excutable finder
1 parent 250ca75 commit 3900ffb

File tree

4 files changed

+8
-27
lines changed

4 files changed

+8
-27
lines changed

composer.json

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
"sebastian/phpcpd": "Lets GrumPHP find duplicated code.",
7979
"squizlabs/php_codesniffer": "Lets GrumPHP sniff on your code.",
8080
"sstalle/php7cc": "Lets GrumPHP check PHP 5.3 - 5.6 code compatibility with PHP 7.",
81-
"symfony/console": "Lets GrumPHP run Symfony Console commands.",
8281
"symfony/phpunit-bridge": "Lets GrumPHP run your unit tests with the phpunit-bridge of Symfony.",
8382
"symplify/easy-coding-standard": "Lets GrumPHP check coding standard.",
8483
"vimeo/psalm": "Lets GrumPHP discover errors in your code without running it.",

doc/tasks/symfony_console.md

+2-6
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,9 @@
22

33
Run a symfony console command.
44

5-
## Composer
5+
## Requirements
66

7-
Requires the Symfony Console component: [Console Component](https://symfony.com/components/Console)
8-
9-
```bash
10-
composer require symfony/console
11-
```
7+
This task requires a Symfony application with console component.
128

139
## Config
1410

src/Task/SymfonyConsole.php

+1-7
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
use GrumPHP\Task\Context\GitPreCommitContext;
1313
use GrumPHP\Task\Context\RunContext;
1414
use Symfony\Component\OptionsResolver\OptionsResolver;
15-
use Symfony\Component\Process\PhpExecutableFinder;
1615

1716
/** @extends AbstractExternalTask<ProcessFormatterInterface> */
1817
class SymfonyConsole extends AbstractExternalTask
@@ -65,12 +64,7 @@ public function run(ContextInterface $context): TaskResultInterface
6564
return TaskResult::createSkipped($this, $context);
6665
}
6766

68-
$php = (new PhpExecutableFinder())->find();
69-
if (false === $php) {
70-
return TaskResult::createFailed($this, $context, 'Unable to locate the PHP executable.');
71-
}
72-
73-
$arguments = $this->processBuilder->createArgumentsForCommand($php);
67+
$arguments = $this->processBuilder->createArgumentsForCommand('php');
7468
$arguments->add($config['bin']);
7569
$arguments->addArgumentArray('%s', $config['command']);
7670

test/Unit/Task/SymfonyConsoleTest.php

+5-13
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,9 @@
99
use GrumPHP\Task\SymfonyConsole;
1010
use GrumPHP\Task\TaskInterface;
1111
use GrumPHP\Test\Task\AbstractExternalTaskTestCase;
12-
use Symfony\Component\Process\PhpExecutableFinder;
1312

1413
final class SymfonyConsoleTest extends AbstractExternalTaskTestCase
1514
{
16-
private static string|false $php;
17-
18-
private static function php(): string|false
19-
{
20-
return self::$php ??= (new PhpExecutableFinder())->find();
21-
}
22-
2315
protected function provideTask(): TaskInterface
2416
{
2517
return new SymfonyConsole(
@@ -91,7 +83,7 @@ public function provideFailsOnStuff(): iterable
9183
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
9284
function() {
9385
$process = $this->mockProcess(1);
94-
$this->mockProcessBuilder(self::php(), $process);
86+
$this->mockProcessBuilder('php', $process);
9587
$this->formatter->format($process)->willReturn('nope');
9688
},
9789
'nope'
@@ -106,7 +98,7 @@ public function providePassesOnStuff(): iterable
10698
],
10799
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
108100
function() {
109-
$this->mockProcessBuilder(self::php(), $this->mockProcess());
101+
$this->mockProcessBuilder('php', $this->mockProcess());
110102
}
111103
];
112104

@@ -117,7 +109,7 @@ function() {
117109
],
118110
$this->mockContext(RunContext::class, ['non-related.log']),
119111
function() {
120-
$this->mockProcessBuilder(self::php(), $this->mockProcess());
112+
$this->mockProcessBuilder('php', $this->mockProcess());
121113
}
122114
];
123115
}
@@ -170,7 +162,7 @@ public function provideExternalTaskRuns(): iterable
170162
'command' => ['lint:container']
171163
],
172164
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
173-
self::php(),
165+
'php',
174166
[
175167
'./bin/console',
176168
'lint:container',
@@ -187,7 +179,7 @@ public function provideExternalTaskRuns(): iterable
187179
]
188180
],
189181
$this->mockContext(RunContext::class, ['hello.php', 'hello2.php']),
190-
self::php(),
182+
'php',
191183
[
192184
'./bin/console',
193185
'task:run',

0 commit comments

Comments
 (0)