[BaseCollection] Treat the null index as "no index" only while adding new element, iow. do not treat empty string as "no index" behaviour

This commit is contained in:
Meritoo
2019-09-19 12:33:03 +02:00
parent d8e3d5e7cb
commit 872259e63d
4 changed files with 8 additions and 3 deletions

View File

@@ -2,6 +2,11 @@
Common and useful classes, methods, exceptions etc. Common and useful classes, methods, exceptions etc.
# 1.1.1
1. [BaseCollection] Treat the `null` index as "no index" only while adding new element, iow. do not treat empty
string as "no index" behaviour.
# 1.1.0 # 1.1.0
1. Rename Meritoo\Common\Collection\Collection class to Meritoo\Common\Collection\BaseCollection. 1. Rename Meritoo\Common\Collection\Collection class to Meritoo\Common\Collection\BaseCollection.

View File

@@ -1 +1 @@
1.1.0 1.1.1

View File

@@ -30,7 +30,7 @@ trait AddTrait
return; return;
} }
if (null === $index || '' === $index) { if (null === $index) {
$this->elements[] = $element; $this->elements[] = $element;
return; return;

View File

@@ -438,7 +438,7 @@ class BaseCollectionTest extends BaseTestCase
'This is test 4', 'This is test 4',
'', '',
4, 4,
1, '',
new StringCollection([ new StringCollection([
'test1' => 'I am 1st', 'test1' => 'I am 1st',
'test2' => 'I am 2nd', 'test2' => 'I am 2nd',