Skip to content

Commit

Permalink
bug #38544 [DI] fix dumping env vars (nicolas-grekas)
Browse files Browse the repository at this point in the history
This PR was merged into the 4.4 branch.

Discussion
----------

[DI] fix dumping env vars

| Q             | A
| ------------- | ---
| Branch?       | 4.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | -
| License       | MIT
| Doc PR        | -

Forgotten in #35029
For 4.4 to reduce merge conflicts (it doesn't allow the new chars in 4.4 anyway, #35029 is still needed)

Commits
-------

746a8d1 [DI] fix dumping env vars
  • Loading branch information
nicolas-grekas committed Oct 13, 2020
2 parents a580688 + 746a8d1 commit 75b3d17
Showing 1 changed file with 2 additions and 2 deletions.
Expand Up @@ -1413,7 +1413,7 @@ private function addDefaultParametersMethod(): string
$export = $this->exportParameters([$value]);
$export = explode('0 => ', substr(rtrim($export, " ]\n"), 2, -1), 2);

if (preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDir\.'')/", $export[1])) {
if (preg_match("/\\\$this->(?:getEnv\('(?:[-.\w]*+:)*+\w++'\)|targetDir\.'')/", $export[1])) {
$dynamicPhp[$key] = sprintf('%scase %s: $value = %s; break;', $export[0], $this->export($key), $export[1]);
} else {
$php[] = sprintf('%s%s => %s,', $export[0], $this->export($key), $export[1]);
Expand Down Expand Up @@ -1819,7 +1819,7 @@ private function dumpParameter(string $name): string
return $dumpedValue;
}

if (!preg_match("/\\\$this->(?:getEnv\('(?:\w++:)*+\w++'\)|targetDir\.'')/", $dumpedValue)) {
if (!preg_match("/\\\$this->(?:getEnv\('(?:[-.\w]*+:)*+\w++'\)|targetDir\.'')/", $dumpedValue)) {
return sprintf('$this->parameters[%s]', $this->doExport($name));
}
}
Expand Down

0 comments on commit 75b3d17

Please sign in to comment.