Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Illuminate/Collections/Arr.php
Original file line number Diff line number Diff line change
Expand Up @@ -844,10 +844,10 @@ public static function mapSpread(array $array, callable $callback)
*
* @param array $array
* @param mixed $value
* @param mixed $key
* @param array-key $key
* @return array
*/
public static function prepend($array, $value, $key = null)
public static function prepend($array, $value, $key = '')
{
if (func_num_args() == 2) {
array_unshift($array, $value);
Expand Down
12 changes: 6 additions & 6 deletions tests/Support/SupportArrTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public function testDivide(): void
$this->assertEquals(['first', 'second'], $values);

// Test dividing an array with null key
[$keys, $values] = Arr::divide([null => 'Null', 1 => 'one']);
[$keys, $values] = Arr::divide(['' => 'Null', 1 => 'one']);
$this->assertEquals([null, 1], $keys);
$this->assertEquals(['Null', 'one'], $values);

Expand All @@ -197,7 +197,7 @@ public function testDivide(): void
$this->assertEquals([['one' => 1, 2 => 'second'], 'one'], $values);

// Test dividing an array where the values are arrays
[$keys, $values] = Arr::divide([null => ['one' => 1, 2 => 'second'], 1 => 'one']);
[$keys, $values] = Arr::divide(['' => ['one' => 1, 2 => 'second'], 1 => 'one']);
$this->assertEquals([null, 1], $keys);
$this->assertEquals([['one' => 1, 2 => 'second'], 'one'], $values);
}
Expand Down Expand Up @@ -1044,8 +1044,8 @@ public function testPrepend()
$array = Arr::prepend(['one' => 1, 'two' => 2], 0, 'zero');
$this->assertEquals(['zero' => 0, 'one' => 1, 'two' => 2], $array);

$array = Arr::prepend(['one' => 1, 'two' => 2], 0, null);
$this->assertEquals([null => 0, 'one' => 1, 'two' => 2], $array);
$array = Arr::prepend(['one' => 1, 'two' => 2], 0, '');
$this->assertEquals(['' => 0, 'one' => 1, 'two' => 2], $array);

$array = Arr::prepend(['one', 'two'], null, '');
$this->assertEquals(['' => null, 'one', 'two'], $array);
Expand Down Expand Up @@ -1547,9 +1547,9 @@ public function testForget()
Arr::forget($array, 'products.desk.final.taxes');
$this->assertEquals(['products' => ['desk' => ['price' => ['original' => 50, 'taxes' => 60]]]], $array);

$array = ['products' => ['desk' => ['price' => 50], null => 'something']];
$array = ['products' => ['desk' => ['price' => 50], '' => 'something']];
Arr::forget($array, ['products.amount.all', 'products.desk.price']);
$this->assertEquals(['products' => ['desk' => [], null => 'something']], $array);
$this->assertEquals(['products' => ['desk' => [], '' => 'something']], $array);

// Only works on first level keys
$array = ['[email protected]' => 'Joe', '[email protected]' => 'Jane'];
Expand Down
Loading