改进分页类和数据集类的each方法

This commit is contained in:
thinkphp
2017-09-05 15:12:51 +08:00
parent 495020b7b0
commit b115680a4d
2 changed files with 8 additions and 2 deletions

View File

@@ -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;
}
}