merged branch canni/simple_fixes (PR #3252)

Commits
-------

d02f172 Code readability fixes, removed unneeded typecasts and checks

Discussion
----------

Code readability fixes, removed unneeded typecasts and checks

Bug fix: no
Feature addition: no
Backwards compatibility break: no
Symfony2 tests pass: yes
Fixes the following tickets: -
Todo: -
This commit is contained in:
Fabien Potencier 2012-02-02 12:11:47 +01:00
commit c6207e4898
2 changed files with 10 additions and 14 deletions

View File

@ -12,16 +12,16 @@
namespace Symfony\Tests\Component\Form\Extension\Core\EventListener; namespace Symfony\Tests\Component\Form\Extension\Core\EventListener;
/** /**
* This class is a hand written simplified version of PHP native `ArrayObject` * This class is a hand written simplified version of PHP native `ArrayObject`
* class, to show that it behaves differently than the PHP native implementation. * class, to show that it behaves differently than the PHP native implementation.
*/ */
class MergeCollectionListenerCustomArrayObjectTest_CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable class MergeCollectionListenerCustomArrayObjectTest_CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable
{ {
private $array; private $array;
public function __construct(array $array = null) public function __construct(array $array = null)
{ {
$this->array = (array) ($array ?: array()); $this->array = $array ?: array();
} }
public function offsetExists($offset) public function offsetExists($offset)
@ -45,9 +45,7 @@ class MergeCollectionListenerCustomArrayObjectTest_CustomArrayObject implements
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
if (array_key_exists($offset, $this->array)) { unset($this->array[$offset]);
unset($this->array[$offset]);
}
} }
public function getIterator() public function getIterator()

View File

@ -12,16 +12,16 @@
namespace Symfony\Tests\Component\Validator\Constraints; namespace Symfony\Tests\Component\Validator\Constraints;
/** /**
* This class is a hand written simplified version of PHP native `ArrayObject` * This class is a hand written simplified version of PHP native `ArrayObject`
* class, to show that it behaves different than PHP native implementation. * class, to show that it behaves differently than the PHP native implementation.
*/ */
class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable, \Serializable
{ {
private $array; private $array;
public function __construct(array $array = null) public function __construct(array $array = null)
{ {
$this->array = (array) ($array ?: array()); $this->array = $array ?: array();
} }
public function offsetExists($offset) public function offsetExists($offset)
@ -45,9 +45,7 @@ class CustomArrayObject implements \ArrayAccess, \IteratorAggregate, \Countable,
public function offsetUnset($offset) public function offsetUnset($offset)
{ {
if (array_key_exists($offset, $this->array)) { unset($this->array[$offset]);
unset($this->array[$offset]);
}
} }
public function getIterator() public function getIterator()