bug #30511 [Process] fix using argument $php of new PhpProcess() (nicolas-grekas)
This PR was merged into the 4.2 branch.
Discussion
----------
[Process] fix using argument $php of new PhpProcess()
| Q | A
| ------------- | ---
| Branch? | 4.2
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -
The current logic makes no sense. 3.4 is fine.
Commits
-------
aa6e5851f1
[Process] fix using argument $php of new PhpProcess()
This commit is contained in:
commit
00fe6e6e2a
@ -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)
|
public function __construct(string $script, string $cwd = null, array $env = null, int $timeout = 60, array $php = null)
|
||||||
{
|
{
|
||||||
$executableFinder = new PhpExecutableFinder();
|
if (null === $php) {
|
||||||
if (false === $php = $php ?? $executableFinder->find(false)) {
|
$executableFinder = new PhpExecutableFinder();
|
||||||
$php = null;
|
$php = $executableFinder->find(false);
|
||||||
} else {
|
$php = false === $php ? null : array_merge([$php], $executableFinder->findArguments());
|
||||||
$php = array_merge([$php], $executableFinder->findArguments());
|
|
||||||
}
|
}
|
||||||
if ('phpdbg' === \PHP_SAPI) {
|
if ('phpdbg' === \PHP_SAPI) {
|
||||||
$file = tempnam(sys_get_temp_dir(), 'dbg');
|
$file = tempnam(sys_get_temp_dir(), 'dbg');
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
namespace Symfony\Component\Process\Tests;
|
namespace Symfony\Component\Process\Tests;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Symfony\Component\Process\PhpExecutableFinder;
|
||||||
use Symfony\Component\Process\PhpProcess;
|
use Symfony\Component\Process\PhpProcess;
|
||||||
|
|
||||||
class PhpProcessTest extends TestCase
|
class PhpProcessTest extends TestCase
|
||||||
@ -45,4 +46,18 @@ PHP
|
|||||||
|
|
||||||
$this->assertSame(PHP_VERSION.\PHP_SAPI, $process->getOutput());
|
$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 = <<<PHP
|
||||||
|
<?php echo '$expected';
|
||||||
|
PHP;
|
||||||
|
$process = new PhpProcess($script, null, null, 60, $php);
|
||||||
|
$process->run();
|
||||||
|
$this->assertEquals($expected, $process->getOutput());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user