Skip to content

Commit 3306c70

Browse files
ro0NLfabpot
authored andcommitted
[DI] Cleanup array_key_exists
1 parent 386e5e7 commit 3306c70

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

src/Symfony/Component/DependencyInjection/Container.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,6 @@ 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)
227226
) {
228227
return true;
229228
}
@@ -266,7 +265,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
266265
$id = $this->aliases[$id];
267266
}
268267
// Re-use shared service instance if it exists.
269-
if (isset($this->services[$id]) || array_key_exists($id, $this->services)) {
268+
if (isset($this->services[$id])) {
270269
return $this->services[$id];
271270
}
272271

@@ -348,7 +347,7 @@ public function initialized($id)
348347
$id = $this->aliases[$id];
349348
}
350349

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

354353
/**

src/Symfony/Component/DependencyInjection/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 (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) {
439+
if (!isset($this->definitions[$id]) && 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 array_key_exists(strtolower($id), $this->definitions);
787+
return isset($this->definitions[strtolower($id)]);
788788
}
789789

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

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

0 commit comments

Comments
 (0)