Skip to content

Commit c09a0fd

Browse files
committed
use foreach
1 parent 337e0e8 commit c09a0fd

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/Illuminate/Support/Collection.php

+5-2
Original file line numberDiff line numberDiff line change
@@ -884,16 +884,19 @@ public function mapToDictionary(callable $callback)
884884
{
885885
$dictionary = [];
886886

887-
$this->each(function ($item, $key) use (&$dictionary, $callback) {
887+
foreach ($this->items as $key => $item) {
888888
$pair = $callback($item, $key);
889+
889890
$key = key($pair);
891+
890892
$value = reset($pair);
891893

892894
if (! isset($dictionary[$key])) {
893895
$dictionary[$key] = [];
894896
}
897+
895898
$dictionary[$key][] = $value;
896-
});
899+
}
897900

898901
return new static($dictionary);
899902
}

0 commit comments

Comments
 (0)