Skip to content

Commit

Permalink
Update pluck documentation to accept array (#17649)
Browse files Browse the repository at this point in the history
* Update docblock of Collection::pluck to accept array

Since Arr::pluck accepts it as well: https://github.com/laravel/framework/blob/01be2355d40bcacaaf06ae6b21d1d687d0d07dd2/src/Illuminate/Support/Arr.php#L344

* Add test where pluck is called with an array

Just to enhance the documentation function of tests.
  • Loading branch information
balping authored and taylorotwell committed Jan 29, 2017
1 parent a25f586 commit d53541c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Illuminate/Support/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ public function last(callable $callback = null, $default = null)
/**
* Get the values of a given key.
*
* @param string $value
* @param string|array $value
* @param string|null $key
* @return static
*/
Expand Down
10 changes: 10 additions & 0 deletions tests/Support/SupportArrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,16 @@ public function testPluck()
$this->assertEquals(['Taylor', 'Abigail'], $array);
}

public function testPluckWithArrayValue()
{
$array = [
['developer' => ['name' => 'Taylor']],
['developer' => ['name' => 'Abigail']],
];
$array = Arr::pluck($array, ['developer', 'name']);
$this->assertEquals(['Taylor', 'Abigail'], $array);
}

public function testPluckWithKeys()
{
$array = [
Expand Down

0 comments on commit d53541c

Please sign in to comment.