Collection > add() method > treat empty string as not provided index (same as null)

This commit is contained in:
Meritoo
2018-06-22 08:04:52 +02:00
parent 107480d01b
commit 5c9436e4e2
4 changed files with 116 additions and 13 deletions

View File

@@ -109,7 +109,7 @@ class Collection implements Countable, ArrayAccess, IteratorAggregate
*/
public function add($element, $index = null)
{
if (null === $index) {
if (null === $index || '' === $index) {
$this->elements[] = $element;
} else {
$this->elements[$index] = $element;