Skip to content

Commit ad3b789

Browse files
committed
[DependencyInjection] Reset resolved state when setting a parameter
1 parent dd745cc commit ad3b789

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/Symfony/Component/DependencyInjection/ParameterBag/ParameterBag.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ public function set(string $name, array|bool|string|int|float|\UnitEnum|null $va
112112
}
113113

114114
$this->parameters[$name] = $value;
115+
$this->resolved = false;
115116
}
116117

117118
/**

src/Symfony/Component/DependencyInjection/Tests/ParameterBag/ParameterBagTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,21 @@ public static function stringsWithSpacesProvider()
356356
['50% is less than 100%', '50% is less than 100%', 'Text between % signs is allowed, if there are spaces.'],
357357
];
358358
}
359+
360+
public function testAddParametersAfterResolveBreaksConsistency()
361+
{
362+
$bag = new ParameterBag(['kernel.project_dir' => '/var/www/my_project']);
363+
$bag->resolve();
364+
365+
$this->assertTrue($bag->isResolved());
366+
367+
$bag->set('app.uploads_dir', '%kernel.project_dir%/public/uploads');
368+
$bag->resolve();
369+
370+
$this->assertSame(
371+
'/var/www/my_project/public/uploads',
372+
$bag->get('app.uploads_dir'),
373+
'ParameterBag failed to resolve new parameters added after initial resolution.'
374+
);
375+
}
359376
}

0 commit comments

Comments
 (0)