symfony/symfony — pull request #11738 by kerdany (2014-08-22 14:06:30+00:00)
Title: [DependencyInjection] Cache resolved parameter values

| 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 simple $resolvedParameters private field in ParameterBag to cache resolved parameters while resolving the ParameterBag.
Did some refactoring, and created a new public method 'resolveParameter($name)', that caches (and looks up) resolved parameter values before returning them.

NOTES:
- Based on 2.5 since this is not a bug fix.
- No change in behavior, and thus no new tests were created.