Skip to content

Use isset() instead of array_key_exists() in DIC #8907

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Use isset() instead of array_key_exists().
  • Loading branch information
Nathaniel Catchpole committed Sep 1, 2013
commit 77b1e496b5466c527bb4cb1b2a59b51b3010bb07
8 changes: 4 additions & 4 deletions src/Symfony/Component/DependencyInjection/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,8 @@ public function has($id)
{
$id = strtolower($id);

return array_key_exists($id, $this->services)
|| array_key_exists($id, $this->aliases)
return isset($this->services[$id])
|| isset($this->aliases[$id])
|| method_exists($this, 'get'.strtr($id, array('_' => '', '.' => '_')).'Service')
;
}
Expand Down Expand Up @@ -275,7 +275,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
}

// re-use shared service instance if it exists
if (array_key_exists($id, $this->services)) {
if (isset($this->services[$id])) {
return $this->services[$id];
}

Expand Down Expand Up @@ -339,7 +339,7 @@ public function get($id, $invalidBehavior = self::EXCEPTION_ON_INVALID_REFERENCE
*/
public function initialized($id)
{
return array_key_exists(strtolower($id), $this->services);
return isset($this->services[strtolower($id)]);
}

/**
Expand Down