diff --git a/library/think/Collection.php b/library/think/Collection.php index 41b42759..d88c3183 100644 --- a/library/think/Collection.php +++ b/library/think/Collection.php @@ -189,8 +189,11 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria public function each(callable $callback) { foreach ($this->items as $key => $item) { - if ($callback($item, $key) === false) { + $result = $callback($item, $key); + if (false === $result) { break; + } elseif (!is_object($item)) { + $this->items[$key] = $result; } } diff --git a/library/think/Paginator.php b/library/think/Paginator.php index 6a9dfe41..39d2f644 100644 --- a/library/think/Paginator.php +++ b/library/think/Paginator.php @@ -288,8 +288,11 @@ abstract class Paginator implements ArrayAccess, Countable, IteratorAggregate, J public function each(callable $callback) { foreach ($this->items as $key => $item) { - if ($callback($item, $key) === false) { + $result = $callback($item, $key); + if (false === $result) { break; + } elseif (!is_object($item)) { + $this->items[$key] = $result; } }