diff --git a/src/Symfony/Component/Process/PhpProcess.php b/src/Symfony/Component/Process/PhpProcess.php index 6ebf7377ce..126d9b754f 100644 --- a/src/Symfony/Component/Process/PhpProcess.php +++ b/src/Symfony/Component/Process/PhpProcess.php @@ -33,11 +33,10 @@ class PhpProcess extends Process */ public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60, array $php = null) { - $executableFinder = new PhpExecutableFinder(); - if (false === $php = $php ?? $executableFinder->find(false)) { - $php = null; - } else { - $php = array_merge([$php], $executableFinder->findArguments()); + if (null === $php) { + $executableFinder = new PhpExecutableFinder(); + $php = $executableFinder->find(false); + $php = false === $php ? null : array_merge([$php], $executableFinder->findArguments()); } if ('phpdbg' === \PHP_SAPI) { $file = tempnam(sys_get_temp_dir(), 'dbg'); diff --git a/src/Symfony/Component/Process/Tests/PhpProcessTest.php b/src/Symfony/Component/Process/Tests/PhpProcessTest.php index b0f0a57ace..0355c85be6 100644 --- a/src/Symfony/Component/Process/Tests/PhpProcessTest.php +++ b/src/Symfony/Component/Process/Tests/PhpProcessTest.php @@ -12,6 +12,7 @@ namespace Symfony\Component\Process\Tests; use PHPUnit\Framework\TestCase; +use Symfony\Component\Process\PhpExecutableFinder; use Symfony\Component\Process\PhpProcess; class PhpProcessTest extends TestCase @@ -45,4 +46,18 @@ PHP $this->assertSame(PHP_VERSION.\PHP_SAPI, $process->getOutput()); } + + public function testPassingPhpExplicitly() + { + $finder = new PhpExecutableFinder(); + $php = array_merge([$finder->find(false)], $finder->findArguments()); + + $expected = 'hello world!'; + $script = <<run(); + $this->assertEquals($expected, $process->getOutput()); + } }