[DI] fix removing non-shared definition while inlining them
This commit is contained in:
parent
ebe9ccf0cc
commit
317e820694
@ -60,6 +60,7 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
|||||||
$analyzedContainer = $container;
|
$analyzedContainer = $container;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
$remainingInlinedIds = [];
|
||||||
$this->connectedIds = $this->notInlinedIds = $container->getDefinitions();
|
$this->connectedIds = $this->notInlinedIds = $container->getDefinitions();
|
||||||
do {
|
do {
|
||||||
if ($this->analyzingPass) {
|
if ($this->analyzingPass) {
|
||||||
@ -83,8 +84,10 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($this->inlinedIds as $id => $isPublic) {
|
foreach ($this->inlinedIds as $id => $isPublicOrNotShared) {
|
||||||
if (!$isPublic) {
|
if ($isPublicOrNotShared) {
|
||||||
|
$remainingInlinedIds[$id] = $id;
|
||||||
|
} else {
|
||||||
$container->removeDefinition($id);
|
$container->removeDefinition($id);
|
||||||
$analyzedContainer->removeDefinition($id);
|
$analyzedContainer->removeDefinition($id);
|
||||||
}
|
}
|
||||||
@ -94,6 +97,14 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
|||||||
if ($this->inlinedIds && $this->repeatedPass) {
|
if ($this->inlinedIds && $this->repeatedPass) {
|
||||||
$this->repeatedPass->setRepeat();
|
$this->repeatedPass->setRepeat();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($remainingInlinedIds as $id) {
|
||||||
|
$definition = $container->getDefinition($id);
|
||||||
|
|
||||||
|
if (!$definition->isShared() && !$definition->isPublic()) {
|
||||||
|
$container->removeDefinition($id);
|
||||||
|
}
|
||||||
|
}
|
||||||
} finally {
|
} finally {
|
||||||
$this->container = null;
|
$this->container = null;
|
||||||
$this->connectedIds = $this->notInlinedIds = $this->inlinedIds = [];
|
$this->connectedIds = $this->notInlinedIds = $this->inlinedIds = [];
|
||||||
@ -131,7 +142,7 @@ class InlineServiceDefinitionsPass extends AbstractRecursivePass implements Repe
|
|||||||
}
|
}
|
||||||
|
|
||||||
$this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId));
|
$this->container->log($this, sprintf('Inlined service "%s" to "%s".', $id, $this->currentId));
|
||||||
$this->inlinedIds[$id] = $definition->isPublic();
|
$this->inlinedIds[$id] = $definition->isPublic() || !$definition->isShared();
|
||||||
$this->notInlinedIds[$this->currentId] = true;
|
$this->notInlinedIds[$this->currentId] = true;
|
||||||
|
|
||||||
if ($definition->isShared()) {
|
if ($definition->isShared()) {
|
||||||
|
Reference in New Issue
Block a user