Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
[Process] Fix Process::getEnv() when setEnv() hasn't been called before
  • Loading branch information
asika32764 authored and nicolas-grekas committed Apr 4, 2022
commit a5bf7407de0a608f130c1c4c62ecbb4f9101bac7
2 changes: 1 addition & 1 deletion src/Symfony/Component/Process/Process.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class Process implements \IteratorAggregate
private $hasCallback = false;
private $commandline;
private $cwd;
private $env;
private $env = [];
private $input;
private $starttime;
private $lastOutputTime;
Expand Down
5 changes: 4 additions & 1 deletion src/Symfony/Component/Process/Tests/ProcessTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1505,8 +1505,11 @@ public function testPreparedCommandWithNoValues()

public function testEnvArgument()
{
$env = ['FOO' => 'Foo', 'BAR' => 'Bar'];
$cmd = '\\' === \DIRECTORY_SEPARATOR ? 'echo !FOO! !BAR! !BAZ!' : 'echo $FOO $BAR $BAZ';
$p = Process::fromShellCommandline($cmd);
$this->assertSame([], $p->getEnv());

$env = ['FOO' => 'Foo', 'BAR' => 'Bar'];
$p = Process::fromShellCommandline($cmd, null, $env);
$p->run(null, ['BAR' => 'baR', 'BAZ' => 'baZ']);

Expand Down