Merge branch '4.0'

* 4.0:
  [DI] Fix missing "id" normalization when dumping the container
  Add entry for `container.dumper.inline_class_loader` param at `UPGRADE-3.4.md` and `UPGRADE-4.0.md`
This commit is contained in:
Nicolas Grekas 2018-03-02 15:22:00 +01:00
commit a8dc953279
6 changed files with 30 additions and 19 deletions

View File

@ -236,6 +236,17 @@ DependencyInjection
* The `ExtensionCompilerPass` has been moved to before-optimization passes with priority -1000.
* In 3.4, parameter `container.dumper.inline_class_loader` was introduced. Unless
you're using a custom autoloader, you should enable this parameter. This can
drastically improve DX by reducing the time to load classes when the `DebugClassLoader`
is enabled. If you're using `FrameworkBundle`, this performance improvement will
also impact the "dev" environment:
```yml
parameters:
container.dumper.inline_class_loader: true
```
DoctrineBridge
--------------

View File

@ -64,7 +64,8 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
$this->lazy = false;
foreach ($container->getAliases() as $id => $alias) {
$this->graph->connect($id, $alias, (string) $alias, $this->getDefinition((string) $alias), null);
$targetId = $this->getDefinitionId((string) $alias);
$this->graph->connect($id, $alias, $targetId, $this->getDefinition($targetId), null);
}
parent::process($container);
@ -87,12 +88,13 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
return $value;
}
if ($value instanceof Reference) {
$targetDefinition = $this->getDefinition((string) $value);
$targetId = $this->getDefinitionId((string) $value);
$targetDefinition = $this->getDefinition($targetId);
$this->graph->connect(
$this->currentId,
$this->currentDefinition,
$this->getDefinitionId((string) $value),
$targetId,
$targetDefinition,
$value,
$this->lazy || ($targetDefinition && $targetDefinition->isLazy()),
@ -125,10 +127,8 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
return $value;
}
private function getDefinition(string $id): ?Definition
private function getDefinition(?string $id): ?Definition
{
$id = $this->getDefinitionId($id);
return null === $id ? null : $this->container->getDefinition($id);
}
@ -156,11 +156,12 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
$this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) {
if ('""' === substr_replace($arg, '', 1, -1)) {
$id = stripcslashes(substr($arg, 1, -1));
$id = $this->getDefinitionId($id);
$this->graph->connect(
$this->currentId,
$this->currentDefinition,
$this->getDefinitionId($id),
$id,
$this->getDefinition($id)
);
}

View File

@ -90,9 +90,7 @@ class ResolveInvalidReferencesPass implements CompilerPassInterface
$value = array_values($value);
}
} elseif ($value instanceof Reference) {
$id = (string) $value;
if ($this->container->has($id)) {
if ($this->container->has($value)) {
return $value;
}
$invalidBehavior = $value->getInvalidBehavior();

View File

@ -592,7 +592,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*
* @throws BadMethodCallException When this ContainerBuilder is compiled
*/
public function merge(ContainerBuilder $container)
public function merge(self $container)
{
if ($this->isCompiled()) {
throw new BadMethodCallException('Cannot merge on a compiled container.');
@ -1324,16 +1324,16 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
$value = $bag->resolveValue($value);
}
if (is_array($value)) {
if (\is_array($value)) {
$result = array();
foreach ($value as $k => $v) {
$result[$this->resolveEnvPlaceholders($k, $format, $usedEnvs)] = $this->resolveEnvPlaceholders($v, $format, $usedEnvs);
$result[\is_string($k) ? $this->resolveEnvPlaceholders($k, $format, $usedEnvs) : $k] = $this->resolveEnvPlaceholders($v, $format, $usedEnvs);
}
return $result;
}
if (!is_string($value)) {
if (!\is_string($value) || 38 > \strlen($value)) {
return $value;
}
$envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders;

View File

@ -1567,11 +1567,12 @@ EOF;
} elseif ($value instanceof Variable) {
return '$'.$value;
} elseif ($value instanceof Reference) {
if (null !== $this->referenceVariables && isset($this->referenceVariables[$id = (string) $value])) {
$id = (string) $value;
if (null !== $this->referenceVariables && isset($this->referenceVariables[$id])) {
return $this->dumpValue($this->referenceVariables[$id], $interpolate);
}
return $this->getServiceCall((string) $value, $value);
return $this->getServiceCall($id, $value);
} elseif ($value instanceof Expression) {
return $this->getExpressionLanguage()->compile((string) $value, array('this' => 'container'));
} elseif ($value instanceof Parameter) {

View File

@ -171,16 +171,16 @@ class ParameterBag implements ParameterBagInterface
*/
public function resolveValue($value, array $resolving = array())
{
if (is_array($value)) {
if (\is_array($value)) {
$args = array();
foreach ($value as $k => $v) {
$args[$this->resolveValue($k, $resolving)] = $this->resolveValue($v, $resolving);
$args[\is_string($k) ? $this->resolveValue($k, $resolving) : $k] = $this->resolveValue($v, $resolving);
}
return $args;
}
if (!is_string($value)) {
if (!\is_string($value) || 2 > \strlen($value)) {
return $value;
}