From e1406b969bfebd0040e67bf14b39ed03592c2c31 Mon Sep 17 00:00:00 2001 From: yunwuxin <448901948@qq.com> Date: Mon, 11 Jul 2016 10:23:20 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=9B=86=E5=90=88=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/Collection.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/library/think/Collection.php b/library/think/Collection.php index 68097131..3f91b7cb 100644 --- a/library/think/Collection.php +++ b/library/think/Collection.php @@ -42,7 +42,7 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria public function toArray($allow = []) { - return array_map(function ($value) { + return array_map(function ($value) use ($allow) { return ($value instanceof Model || $value instanceof self) ? $value->toArray($allow) : $value; }, $this->items); } @@ -225,11 +225,11 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria $result = []; foreach ($this->items as $row) { - $key = $value = null; + $key = $value = null; $keySet = $valueSet = false; if (null !== $index_key && array_key_exists($index_key, $row)) { $keySet = true; - $key = (string) $row[$index_key]; + $key = (string)$row[$index_key]; } if (null === $column_key) { $valueSet = true; @@ -344,8 +344,8 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria /** * 转换当前数据集为JSON字符串 * @access public - * @param array $allow 允许输出的属性列表 - * @param integer $options json参数 + * @param array $allow 允许输出的属性列表 + * @param integer $options json参数 * @return string */ public function toJson($allow = [], $options = JSON_UNESCAPED_UNICODE) @@ -369,6 +369,6 @@ class Collection implements ArrayAccess, Countable, IteratorAggregate, JsonSeria if ($items instanceof self) { return $items->all(); } - return (array) $items; + return (array)$items; } }