Skip to content

Commit 762e4f7

Browse files
Merge branch '5.3' into 5.4
* 5.3: [Process] filter env vars for "argc" & "argv" specifically
2 parents 2a7d4ed + e498803 commit 762e4f7

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
@@ -340,7 +340,7 @@ public function start(callable $callback = null, array $env = [])
340340

341341
$envPairs = [];
342342
foreach ($env as $k => $v) {
343-
if (false !== $v) {
343+
if (false !== $v && 'argc' !== $k && 'argv' !== $k) {
344344
$envPairs[] = $k.'='.$v;
345345
}
346346
}
@@ -1143,25 +1143,12 @@ public function getEnv()
11431143
/**
11441144
* Sets the environment variables.
11451145
*
1146-
* Each environment variable value should be a string.
1147-
* If it is an array, the variable is ignored.
1148-
* If it is false or null, it will be removed when
1149-
* env vars are otherwise inherited.
1150-
*
1151-
* That happens in PHP when 'argv' is registered into
1152-
* the $_ENV array for instance.
1153-
*
1154-
* @param array $env The new environment variables
1146+
* @param array<string|\Stringable> $env The new environment variables
11551147
*
11561148
* @return $this
11571149
*/
11581150
public function setEnv(array $env)
11591151
{
1160-
// Process cannot handle env values that are arrays
1161-
$env = array_filter($env, function ($value) {
1162-
return !\is_array($value);
1163-
});
1164-
11651152
$this->env = $env;
11661153

11671154
return $this;
@@ -1663,14 +1650,7 @@ private function getDefaultEnv(): array
16631650
{
16641651
$env = getenv();
16651652
$env = array_intersect_key($env, $_SERVER) ?: $env;
1666-
unset($env['argc'], $env['argv']);
1667-
1668-
foreach ($_ENV as $k => $v) {
1669-
if (\is_string($v)) {
1670-
$env[$k] = $v;
1671-
}
1672-
}
16731653

1674-
return $env;
1654+
return $_ENV + $env;
16751655
}
16761656
}

0 commit comments

Comments
 (0)