Skip to content

Commit b74482e

Browse files
Revert "minor #19689 [DI] Cleanup array_key_exists (ro0NL)"
This reverts commit c89f80a9cd3f291159ba5e466c7c968cf15d476a, reversing changes made to 386e5e78b4ad8356fe01ac5406872a56b5177134.
1 parent 31adf72 commit b74482e

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

Container.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ public function has($id)
223223
if ('service_container' === $id
224224
|| isset($this->aliases[$id])
225225
|| isset($this->services[$id])
226+
|| array_key_exists($id, $this->services)
226227
) {
227228
return true;
228229
}
@@ -265,7 +266,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
265266
$id = $this->aliases[$id];
266267
}
267268
// Re-use shared service instance if it exists.
268-
if (isset($this->services[$id])) {
269+
if (isset($this->services[$id]) || array_key_exists($id, $this->services)) {
269270
return $this->services[$id];
270271
}
271272

@@ -347,7 +348,7 @@ public function initialized($id)
347348
$id = $this->aliases[$id];
348349
}
349350

350-
return isset($this->services[$id]);
351+
return isset($this->services[$id]) || array_key_exists($id, $this->services);
351352
}
352353

353354
/**

ContainerBuilder.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ public function get($id, $invalidBehavior = ContainerInterface::EXCEPTION_ON_INV
436436
return $service;
437437
}
438438

439-
if (!isset($this->definitions[$id]) && isset($this->aliasDefinitions[$id])) {
439+
if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) {
440440
return $this->get($this->aliasDefinitions[$id]);
441441
}
442442

@@ -784,7 +784,7 @@ public function setDefinition($id, Definition $definition)
784784
*/
785785
public function hasDefinition($id)
786786
{
787-
return isset($this->definitions[strtolower($id)]);
787+
return array_key_exists(strtolower($id), $this->definitions);
788788
}
789789

790790
/**
@@ -800,7 +800,7 @@ public function getDefinition($id)
800800
{
801801
$id = strtolower($id);
802802

803-
if (!isset($this->definitions[$id])) {
803+
if (!array_key_exists($id, $this->definitions)) {
804804
throw new ServiceNotFoundException($id);
805805
}
806806

0 commit comments

Comments
 (0)