Skip to content

Commit b42b1a1

Browse files
Merge branch '3.3' into 3.4
* 3.3: [DI] Resolve aliases earlier [DI] Mark Container::$privates as internal [DI] Minor dumping logic simplification bumped Symfony version to 3.3.6 updated VERSION for 3.3.5 updated CHANGELOG for 3.3.5 bumped Symfony version to 3.2.13 updated VERSION for 3.2.12 updated CHANGELOG for 3.2.12 bumped Symfony version to 2.8.26 updated VERSION for 2.8.25 updated CHANGELOG for 2.8.25 bumped Symfony version to 2.7.33 updated VERSION for 2.7.32 update CONTRIBUTORS for 2.7.32 updated CHANGELOG for 2.7.32
2 parents 24a3812 + 0eb8dbf commit b42b1a1

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

Container.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@ class Container implements ResettableContainerInterface
5656

5757
protected $services = array();
5858
protected $methodMap = array();
59-
protected $privates = array();
6059
protected $aliases = array();
6160
protected $loading = array();
6261

62+
/**
63+
* @internal
64+
*/
65+
protected $privates = array();
66+
6367
/**
6468
* @internal
6569
*/
@@ -221,15 +225,15 @@ public function has($id)
221225
if (isset($this->privates[$id])) {
222226
@trigger_error(sprintf('Checking for the existence of the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
223227
}
224-
if ('service_container' === $id) {
225-
return true;
226-
}
227228
if (isset($this->aliases[$id])) {
228229
$id = $this->aliases[$id];
229230
}
230231
if (isset($this->services[$id])) {
231232
return true;
232233
}
234+
if ('service_container' === $id) {
235+
return true;
236+
}
233237

234238
if (isset($this->methodMap[$id])) {
235239
return true;
@@ -279,9 +283,6 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
279283
if (isset($this->privates[$id])) {
280284
@trigger_error(sprintf('Requesting the "%s" private service is deprecated since Symfony 3.2 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
281285
}
282-
if ('service_container' === $id) {
283-
return $this;
284-
}
285286
if (isset($this->aliases[$id])) {
286287
$id = $this->aliases[$id];
287288
}
@@ -290,6 +291,9 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
290291
if (isset($this->services[$id])) {
291292
return $this->services[$id];
292293
}
294+
if ('service_container' === $id) {
295+
return $this;
296+
}
293297

294298
if (isset($this->loading[$id])) {
295299
throw new ServiceCircularReferenceException($id, array_keys($this->loading));
@@ -352,10 +356,6 @@ public function initialized($id)
352356
{
353357
$id = $this->normalizeId($id);
354358

355-
if ('service_container' === $id) {
356-
return false;
357-
}
358-
359359
if (isset($this->privates[$id])) {
360360
@trigger_error(sprintf('Checking for the initialization of the "%s" private service is deprecated since Symfony 3.4 and won\'t be supported anymore in Symfony 4.0.', $id), E_USER_DEPRECATED);
361361
}
@@ -364,6 +364,10 @@ public function initialized($id)
364364
$id = $this->aliases[$id];
365365
}
366366

367+
if ('service_container' === $id) {
368+
return false;
369+
}
370+
367371
return isset($this->services[$id]);
368372
}
369373

Dumper/PhpDumper.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1605,6 +1605,10 @@ private function dumpParameter($name)
16051605
*/
16061606
private function getServiceCall($id, Reference $reference = null)
16071607
{
1608+
while ($this->container->hasAlias($id)) {
1609+
$id = (string) $this->container->getAlias($id);
1610+
}
1611+
16081612
if ('service_container' === $id) {
16091613
return '$this';
16101614
}
@@ -1621,7 +1625,7 @@ private function getServiceCall($id, Reference $reference = null)
16211625
$code = sprintf('$this->get(\'%s\')', $id);
16221626
}
16231627

1624-
if ($this->container->hasDefinition($id) && (!$this->container->getDefinition($id)->isPublic() || $this->container->getDefinition($id)->isShared())) {
1628+
if ($this->container->hasDefinition($id) && $this->container->getDefinition($id)->isShared()) {
16251629
// The following is PHP 5.5 syntax for what could be written as "(\$this->services['$id'] ?? $code)" on PHP>=7.0
16261630

16271631
$code = "\${(\$_ = isset(\$this->services['$id']) ? \$this->services['$id'] : $code) && false ?: '_'}";

0 commit comments

Comments
 (0)