Skip to content

Commit 5be20b3

Browse files
Merge branch '5.3' into 5.4
* 5.3: [Process] intersect with getenv() in case-insensitive manner to get default envs [Serializer] fix support for lazy/unset properties Fix redundant type casts [Notifier] Fix AllMySms bridge body content Revert "[DoctrineBridge] add support for the JSON type"
2 parents e8f02d0 + 75c91d6 commit 5be20b3

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

Process.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,10 @@ public function start(callable $callback = null, array $env = [])
307307
$descriptors = $this->getDescriptors();
308308

309309
if ($this->env) {
310-
$env += $this->env;
310+
$env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->env, $env, 'strcasecmp') : $this->env;
311311
}
312312

313-
$env += $this->getDefaultEnv();
313+
$env += '\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($this->getDefaultEnv(), $env, 'strcasecmp') : $this->getDefaultEnv();
314314

315315
if (\is_array($commandline = $this->commandline)) {
316316
$commandline = implode(' ', array_map([$this, 'escapeArgument'], $commandline));
@@ -1649,8 +1649,8 @@ private function replacePlaceholders(string $commandline, array $env)
16491649
private function getDefaultEnv(): array
16501650
{
16511651
$env = getenv();
1652-
$env = array_intersect_key($env, $_SERVER) ?: $env;
1652+
$env = ('\\' === \DIRECTORY_SEPARATOR ? array_intersect_ukey($env, $_SERVER, 'strcasecmp') : array_intersect_key($env, $_SERVER)) ?: $env;
16531653

1654-
return $_ENV + $env;
1654+
return $_ENV + ('\\' === \DIRECTORY_SEPARATOR ? array_diff_ukey($env, $_ENV, 'strcasecmp') : $env);
16551655
}
16561656
}

Tests/ProcessTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1522,6 +1522,18 @@ public function testWaitStoppedDeadProcess()
15221522
$this->assertFalse($process->isRunning());
15231523
}
15241524

1525+
public function testEnvCaseInsensitiveOnWindows()
1526+
{
1527+
$p = $this->getProcessForCode('print_r([$_SERVER[\'PATH\'] ?? 1, $_SERVER[\'Path\'] ?? 2]);', null, ['PATH' => 'bar/baz']);
1528+
$p->run(null, ['Path' => 'foo/bar']);
1529+
1530+
if ('\\' === \DIRECTORY_SEPARATOR) {
1531+
$this->assertSame('Array ( [0] => 1 [1] => foo/bar )', preg_replace('/\s++/', ' ', trim($p->getOutput())));
1532+
} else {
1533+
$this->assertSame('Array ( [0] => bar/baz [1] => foo/bar )', preg_replace('/\s++/', ' ', trim($p->getOutput())));
1534+
}
1535+
}
1536+
15251537
/**
15261538
* @param string|array $commandline
15271539
* @param mixed $input

0 commit comments

Comments
 (0)