symfony/symfony — pull request #11741 by kerdany (2014-08-22 22:50:09+00:00)
Title: [DependencyInjection] Cache resolved parameter values in ParameterBag

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | -
| License | MIT
| Doc PR | -

**Problem:**
The ParameterBag's method 'resolveValue()' recursively resolves parameters referenced inside other parameters' values every time.
However, if a parameter is referenced (i.e. %name%) two or more times inside other parameters' values, it's recursively resolved every time.

**Solution:**
Added a `resolvedParameters` private array field in ParameterBag to cache resolved parameters while resolving the ParameterBag (via `resolve()`), or while resolving any string or parameter (via `resolveValue()` or `resolveString()`).
Did some refactoring, and created a new public method 'resolveParameter()', that caches (and looks up) resolved parameter values before returning them.
The caching array is reset every time parameters are modified via either `set`, `add`, `remove`, `clear`.

**Tests:**
Added a `testResolveAfterSettingAddingRemovingClearingParameters()` test, to make sure that parameter values are refreshed after being resolved then modified.

**NOTES:**
- Based on master since this is not a bug fix.