Skip to content

Commit f98e3ad

Browse files
authored
Merge pull request #20 from acrossmountain/3.0
添加集合新增时 链式操作
2 parents 04a0f6f + 812e00f commit f98e3ad

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/Collection.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -242,15 +242,17 @@ public function shift()
242242
* @access public
243243
* @param mixed $value 元素
244244
* @param string $key KEY
245-
* @return void
245+
* @return $this
246246
*/
247-
public function push($value, string $key = null): void
247+
public function push($value, string $key = null)
248248
{
249249
if (is_null($key)) {
250250
$this->items[] = $value;
251251
} else {
252252
$this->items[$key] = $value;
253253
}
254+
255+
return $this;
254256
}
255257

256258
/**
@@ -277,15 +279,17 @@ public function chunk(int $size, bool $preserveKeys = false)
277279
* @access public
278280
* @param mixed $value 元素
279281
* @param string $key KEY
280-
* @return void
282+
* @return $this
281283
*/
282-
public function unshift($value, string $key = null): void
284+
public function unshift($value, string $key = null)
283285
{
284286
if (is_null($key)) {
285287
array_unshift($this->items, $value);
286288
} else {
287289
$this->items = [$key => $value] + $this->items;
288290
}
291+
292+
return $this;
289293
}
290294

291295
/**

0 commit comments

Comments
 (0)