[DI] Cleanup array_key_exists

This commit is contained in:
Roland Franssen 2016-08-21 12:01:27 +00:00 committed by Fabien Potencier
parent 386e5e78b4
commit 3306c70a34
2 changed files with 5 additions and 6 deletions

View File

@ -223,7 +223,6 @@ class Container implements IntrospectableContainerInterface
if ('service_container' === $id if ('service_container' === $id
|| isset($this->aliases[$id]) || isset($this->aliases[$id])
|| isset($this->services[$id]) || isset($this->services[$id])
|| array_key_exists($id, $this->services)
) { ) {
return true; return true;
} }
@ -266,7 +265,7 @@ class Container implements IntrospectableContainerInterface
$id = $this->aliases[$id]; $id = $this->aliases[$id];
} }
// Re-use shared service instance if it exists. // Re-use shared service instance if it exists.
if (isset($this->services[$id]) || array_key_exists($id, $this->services)) { if (isset($this->services[$id])) {
return $this->services[$id]; return $this->services[$id];
} }
@ -348,7 +347,7 @@ class Container implements IntrospectableContainerInterface
$id = $this->aliases[$id]; $id = $this->aliases[$id];
} }
return isset($this->services[$id]) || array_key_exists($id, $this->services); return isset($this->services[$id]);
} }
/** /**

View File

@ -436,7 +436,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
return $service; return $service;
} }
if (!array_key_exists($id, $this->definitions) && isset($this->aliasDefinitions[$id])) { if (!isset($this->definitions[$id]) && isset($this->aliasDefinitions[$id])) {
return $this->get($this->aliasDefinitions[$id]); return $this->get($this->aliasDefinitions[$id]);
} }
@ -784,7 +784,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
*/ */
public function hasDefinition($id) public function hasDefinition($id)
{ {
return array_key_exists(strtolower($id), $this->definitions); return isset($this->definitions[strtolower($id)]);
} }
/** /**
@ -800,7 +800,7 @@ class ContainerBuilder extends Container implements TaggedContainerInterface
{ {
$id = strtolower($id); $id = strtolower($id);
if (!array_key_exists($id, $this->definitions)) { if (!isset($this->definitions[$id])) {
throw new ServiceNotFoundException($id); throw new ServiceNotFoundException($id);
} }