Skip to content

Commit e498803

Browse files
Merge branch '4.4' into 5.3
* 4.4: [Process] filter env vars for "argc" & "argv" specifically
2 parents e445dab + c209870 commit e498803

File tree

1 file changed

+3
-23
lines changed

1 file changed

+3
-23
lines changed

Process.php

Lines changed: 3 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,7 @@ public function start(callable $callback = null, array $env = [])
338338

339339
$envPairs = [];
340340
foreach ($env as $k => $v) {
341-
if (false !== $v) {
341+
if (false !== $v && 'argc' !== $k && 'argv' !== $k) {
342342
$envPairs[] = $k.'='.$v;
343343
}
344344
}
@@ -1141,25 +1141,12 @@ public function getEnv()
11411141
/**
11421142
* Sets the environment variables.
11431143
*
1144-
* Each environment variable value should be a string.
1145-
* If it is an array, the variable is ignored.
1146-
* If it is false or null, it will be removed when
1147-
* env vars are otherwise inherited.
1148-
*
1149-
* That happens in PHP when 'argv' is registered into
1150-
* the $_ENV array for instance.
1151-
*
1152-
* @param array $env The new environment variables
1144+
* @param array<string|\Stringable> $env The new environment variables
11531145
*
11541146
* @return $this
11551147
*/
11561148
public function setEnv(array $env)
11571149
{
1158-
// Process can not handle env values that are arrays
1159-
$env = array_filter($env, function ($value) {
1160-
return !\is_array($value);
1161-
});
1162-
11631150
$this->env = $env;
11641151

11651152
return $this;
@@ -1661,14 +1648,7 @@ private function getDefaultEnv(): array
16611648
{
16621649
$env = getenv();
16631650
$env = array_intersect_key($env, $_SERVER) ?: $env;
1664-
unset($env['argc'], $env['argv']);
1665-
1666-
foreach ($_ENV as $k => $v) {
1667-
if (\is_string($v)) {
1668-
$env[$k] = $v;
1669-
}
1670-
}
16711651

1672-
return $env;
1652+
return $_ENV + $env;
16731653
}
16741654
}

0 commit comments

Comments
 (0)