Merge branch '3.4' into 4.0
* 3.4: [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:
commit
cb06d0f926
@ -236,6 +236,17 @@ DependencyInjection
|
|||||||
|
|
||||||
* The `ExtensionCompilerPass` has been moved to before-optimization passes with priority -1000.
|
* 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
|
DoctrineBridge
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
|
@ -64,7 +64,8 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
|
|||||||
$this->lazy = false;
|
$this->lazy = false;
|
||||||
|
|
||||||
foreach ($container->getAliases() as $id => $alias) {
|
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);
|
parent::process($container);
|
||||||
@ -87,12 +88,13 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
|
|||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
if ($value instanceof Reference) {
|
if ($value instanceof Reference) {
|
||||||
$targetDefinition = $this->getDefinition((string) $value);
|
$targetId = $this->getDefinitionId((string) $value);
|
||||||
|
$targetDefinition = $this->getDefinition($targetId);
|
||||||
|
|
||||||
$this->graph->connect(
|
$this->graph->connect(
|
||||||
$this->currentId,
|
$this->currentId,
|
||||||
$this->currentDefinition,
|
$this->currentDefinition,
|
||||||
$this->getDefinitionId((string) $value),
|
$targetId,
|
||||||
$targetDefinition,
|
$targetDefinition,
|
||||||
$value,
|
$value,
|
||||||
$this->lazy || ($targetDefinition && $targetDefinition->isLazy()),
|
$this->lazy || ($targetDefinition && $targetDefinition->isLazy()),
|
||||||
@ -125,10 +127,8 @@ class AnalyzeServiceReferencesPass extends AbstractRecursivePass implements Repe
|
|||||||
return $value;
|
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);
|
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) {
|
$this->expressionLanguage = new ExpressionLanguage(null, $providers, function ($arg) {
|
||||||
if ('""' === substr_replace($arg, '', 1, -1)) {
|
if ('""' === substr_replace($arg, '', 1, -1)) {
|
||||||
$id = stripcslashes(substr($arg, 1, -1));
|
$id = stripcslashes(substr($arg, 1, -1));
|
||||||
|
$id = $this->getDefinitionId($id);
|
||||||
|
|
||||||
$this->graph->connect(
|
$this->graph->connect(
|
||||||
$this->currentId,
|
$this->currentId,
|
||||||
$this->currentDefinition,
|
$this->currentDefinition,
|
||||||
$this->getDefinitionId($id),
|
$id,
|
||||||
$this->getDefinition($id)
|
$this->getDefinition($id)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -90,9 +90,7 @@ class ResolveInvalidReferencesPass implements CompilerPassInterface
|
|||||||
$value = array_values($value);
|
$value = array_values($value);
|
||||||
}
|
}
|
||||||
} elseif ($value instanceof Reference) {
|
} elseif ($value instanceof Reference) {
|
||||||
$id = (string) $value;
|
if ($this->container->has($value)) {
|
||||||
|
|
||||||
if ($this->container->has($id)) {
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
$invalidBehavior = $value->getInvalidBehavior();
|
$invalidBehavior = $value->getInvalidBehavior();
|
||||||
|
@ -592,7 +592,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
*
|
*
|
||||||
* @throws BadMethodCallException When this ContainerBuilder is compiled
|
* @throws BadMethodCallException When this ContainerBuilder is compiled
|
||||||
*/
|
*/
|
||||||
public function merge(ContainerBuilder $container)
|
public function merge(self $container)
|
||||||
{
|
{
|
||||||
if ($this->isCompiled()) {
|
if ($this->isCompiled()) {
|
||||||
throw new BadMethodCallException('Cannot merge on a compiled container.');
|
throw new BadMethodCallException('Cannot merge on a compiled container.');
|
||||||
@ -1324,16 +1324,16 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
|
|||||||
$value = $bag->resolveValue($value);
|
$value = $bag->resolveValue($value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_array($value)) {
|
if (\is_array($value)) {
|
||||||
$result = array();
|
$result = array();
|
||||||
foreach ($value as $k => $v) {
|
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;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($value)) {
|
if (!\is_string($value) || 38 > \strlen($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
$envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders;
|
$envPlaceholders = $bag instanceof EnvPlaceholderParameterBag ? $bag->getEnvPlaceholders() : $this->envPlaceholders;
|
||||||
|
@ -1552,11 +1552,12 @@ EOF;
|
|||||||
} elseif ($value instanceof Variable) {
|
} elseif ($value instanceof Variable) {
|
||||||
return '$'.$value;
|
return '$'.$value;
|
||||||
} elseif ($value instanceof Reference) {
|
} 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->dumpValue($this->referenceVariables[$id], $interpolate);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->getServiceCall((string) $value, $value);
|
return $this->getServiceCall($id, $value);
|
||||||
} elseif ($value instanceof Expression) {
|
} elseif ($value instanceof Expression) {
|
||||||
return $this->getExpressionLanguage()->compile((string) $value, array('this' => 'container'));
|
return $this->getExpressionLanguage()->compile((string) $value, array('this' => 'container'));
|
||||||
} elseif ($value instanceof Parameter) {
|
} elseif ($value instanceof Parameter) {
|
||||||
|
@ -171,16 +171,16 @@ class ParameterBag implements ParameterBagInterface
|
|||||||
*/
|
*/
|
||||||
public function resolveValue($value, array $resolving = array())
|
public function resolveValue($value, array $resolving = array())
|
||||||
{
|
{
|
||||||
if (is_array($value)) {
|
if (\is_array($value)) {
|
||||||
$args = array();
|
$args = array();
|
||||||
foreach ($value as $k => $v) {
|
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;
|
return $args;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!is_string($value)) {
|
if (!\is_string($value) || 2 > \strlen($value)) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user