File tree 1 file changed +11
-5
lines changed
Filter options
src/Symfony/Component/DependencyInjection
1 file changed +11
-5
lines changed
Original file line number Diff line number Diff line change @@ -22,6 +22,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
22
22
{
23
23
private $ container ;
24
24
private $ loaders ;
25
+ private $ loadedLoaderIndex = 0 ;
25
26
private $ loadedVars = [];
26
27
27
28
/**
@@ -30,8 +31,7 @@ class EnvVarProcessor implements EnvVarProcessorInterface
30
31
public function __construct (ContainerInterface $ container , \Traversable $ loaders = null )
31
32
{
32
33
$ this ->container = $ container ;
33
- $ this ->loaders = new \IteratorIterator ($ loaders ?? new \ArrayIterator ());
34
- $ this ->loaders = $ this ->loaders ->getInnerIterator ();
34
+ $ this ->loaders = $ loaders ?? new \ArrayIterator ();
35
35
}
36
36
37
37
/**
@@ -145,11 +145,17 @@ public function getEnv($prefix, $name, \Closure $getEnv)
145
145
$ this ->loaders = new \ArrayIterator ();
146
146
147
147
try {
148
- while ((false === $ env || null === $ env ) && $ loaders ->valid ()) {
149
- $ loader = $ loaders ->current ();
150
- $ loaders ->next ();
148
+ $ index = 0 ;
149
+ foreach ($ loaders as $ loader ) {
150
+ if ($ index ++ < $ this ->loadedLoaderIndex ) {
151
+ continue ;
152
+ }
151
153
$ this ->loadedVars [] = $ vars = $ loader ->loadEnvVars ();
154
+ $ this ->loadedLoaderIndex = $ index ;
152
155
$ env = $ vars [$ name ] ?? false ;
156
+ if (false !== $ env ) {
157
+ break ;
158
+ }
153
159
}
154
160
} catch (ParameterCircularReferenceException $ e ) {
155
161
// skip loaders that need an env var that is not defined
You can’t perform that action at this time.
0 commit comments