Skip to content

Commit 12499a1

Browse files
minor #50089 [DependencyInjection] More predictable EnvVarProcessor CSV empty string parsing (andreyserdjuk)
This PR was squashed before being merged into the 6.3 branch. Discussion ---------- [DependencyInjection] More predictable EnvVarProcessor CSV empty string parsing | Q | A | ------------- | --- | Branch? | 6.3 | Bug fix? | no | New feature? | no | Deprecations? | no | License | MIT Small improvement, that solves problem of getting non-empty array: `[0 => null]`, when parse empty string by csv processor. After this fix '%env(csv:EMPTY_STRING)%' will return `[]`, but not `[0 => null]`. Commits ------- aea85f5 [DependencyInjection] More predictable EnvVarProcessor CSV empty string parsing
2 parents b8e918d + aea85f5 commit 12499a1

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Symfony/Component/DependencyInjection/EnvVarProcessor.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -313,7 +313,7 @@ public function getEnv(string $prefix, string $name, \Closure $getEnv): mixed
313313
}
314314

315315
if ('csv' === $prefix) {
316-
return str_getcsv($env, ',', '"', '');
316+
return '' === $env ? [] : str_getcsv($env, ',', '"', '');
317317
}
318318

319319
if ('trim' === $prefix) {

src/Symfony/Component/DependencyInjection/Tests/EnvVarProcessorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,7 +714,7 @@ public static function validCsv()
714714
CSV;
715715

716716
return [
717-
['', [null]],
717+
['', []],
718718
[',', ['', '']],
719719
['1', ['1']],
720720
['1,2," 3 "', ['1', '2', ' 3 ']],

0 commit comments

Comments
 (0)