Permalink
Browse files

Update lib/Doctrine/Common/Collections/ArrayCollection.php

  • Loading branch information...
1 parent d514e39 commit d2ee571009b5a168a7c195f6da7f85a1cf1cefe6 basico committed Dec 17, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 lib/Doctrine/Common/Collections/ArrayCollection.php
@@ -120,7 +120,7 @@ public function current()
*/
public function remove($key)
{
- if (array_key_exists($key, $this->_elements)) {
+ if (isset($this->_elements[$key]) || array_key_exists($key, $this->_elements)) {
@fruit

fruit Jan 8, 2013

Contributor

IMHO, the better way is to reuse here containsKey method:

if ($this->containsKey($key)) { ... }

@Basico, why you want to check with the isset first - performance reasons?

@Ocramius

Ocramius Jan 8, 2013

Owner

Would be much more overhead

@jfcalcerrada

jfcalcerrada Jan 8, 2013

Contributor

Yes, I add two links related about that in the pull request #235

$removed = $this->_elements[$key];
unset($this->_elements[$key]);
@@ -214,7 +214,7 @@ public function offsetUnset($offset)
*/
public function containsKey($key)
{
- return array_key_exists($key, $this->_elements);
+ return isset($this->_elements[$key]) || array_key_exists($key, $this->_elements);
}
/**

0 comments on commit d2ee571

Please sign in to comment.