aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/ramsey/collection/src/AbstractCollection.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/ramsey/collection/src/AbstractCollection.php')
-rw-r--r--vendor/ramsey/collection/src/AbstractCollection.php18
1 files changed, 10 insertions, 8 deletions
diff --git a/vendor/ramsey/collection/src/AbstractCollection.php b/vendor/ramsey/collection/src/AbstractCollection.php
index b1df91923..d2cd1151c 100644
--- a/vendor/ramsey/collection/src/AbstractCollection.php
+++ b/vendor/ramsey/collection/src/AbstractCollection.php
@@ -32,6 +32,7 @@ use function array_uintersect;
use function current;
use function end;
use function in_array;
+use function is_int;
use function reset;
use function sprintf;
use function unserialize;
@@ -238,7 +239,7 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt
public function merge(CollectionInterface ...$collections): CollectionInterface
{
- $temp = [$this->data];
+ $mergedCollection = clone $this;
foreach ($collections as $index => $collection) {
if (!$collection instanceof static) {
@@ -255,15 +256,16 @@ abstract class AbstractCollection extends AbstractArray implements CollectionInt
);
}
- $temp[] = $collection->toArray();
+ foreach ($collection as $key => $value) {
+ if (is_int($key)) {
+ $mergedCollection[] = $value;
+ } else {
+ $mergedCollection[$key] = $value;
+ }
+ }
}
- $merge = array_merge(...$temp);
-
- $collection = clone $this;
- $collection->data = $merge;
-
- return $collection;
+ return $mergedCollection;
}
/**