Skip to content

Commit b07e6d3

Browse files
authored
Fix creating Collection from Generator
1 parent 4383709 commit b07e6d3

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/JarJak/Collection/Collection.php

+5-8
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,15 @@ public function __construct(...$items)
1010
{
1111
parent::__construct(\count($items));
1212

13-
foreach (array_values($items) as $i => $item) {
14-
$this[$i] = $item;
13+
$i = 0;
14+
foreach ($items as $item) {
15+
$this[$i++] = $item;
1516
}
1617
}
1718

18-
public static function from(iterable $array)
19+
public static function from(iterable $iterable)
1920
{
20-
if (\is_array($array) || $array instanceof \ArrayAccess) {
21-
return new static(...$array);
22-
}
23-
24-
return new static(...$array);
21+
return new static(...$iterable);
2522
}
2623

2724
public function isEmpty(): bool

0 commit comments

Comments
 (0)