Skip to content

Commit 9eedd60

Browse files
asika32764nicolas-grekas
authored andcommitted
[Process] Fix Process::getEnv() when setEnv() hasn't been called before
1 parent 54e9d76 commit 9eedd60

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

Process.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class Process implements \IteratorAggregate
5353
private $hasCallback = false;
5454
private $commandline;
5555
private $cwd;
56-
private $env;
56+
private $env = [];
5757
private $input;
5858
private $starttime;
5959
private $lastOutputTime;

Tests/ProcessTest.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -1505,8 +1505,11 @@ public function testPreparedCommandWithNoValues()
15051505

15061506
public function testEnvArgument()
15071507
{
1508-
$env = ['FOO' => 'Foo', 'BAR' => 'Bar'];
15091508
$cmd = '\\' === \DIRECTORY_SEPARATOR ? 'echo !FOO! !BAR! !BAZ!' : 'echo $FOO $BAR $BAZ';
1509+
$p = Process::fromShellCommandline($cmd);
1510+
$this->assertSame([], $p->getEnv());
1511+
1512+
$env = ['FOO' => 'Foo', 'BAR' => 'Bar'];
15101513
$p = Process::fromShellCommandline($cmd, null, $env);
15111514
$p->run(null, ['BAR' => 'baR', 'BAZ' => 'baZ']);
15121515

0 commit comments

Comments
 (0)