Skip to content

Commit 31e6062

Browse files
authored
fix method doctypes of Arr Support class (#41488)
1 parent bf4496e commit 31e6062

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

src/Illuminate/Collections/Arr.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ public static function accessible($value)
2525
* Add an element to an array using "dot" notation if it doesn't exist.
2626
*
2727
* @param array $array
28-
* @param string $key
28+
* @param string|int|float $key
2929
* @param mixed $value
3030
* @return array
3131
*/
@@ -599,7 +599,7 @@ public static function random($array, $number = null, $preserveKeys = false)
599599
* If no key is given to the method, the entire array will be replaced.
600600
*
601601
* @param array $array
602-
* @param string|null $key
602+
* @param string|int|null $key
603603
* @param mixed $value
604604
* @return array
605605
*/

tests/Support/SupportArrTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ public function testAdd()
3232

3333
$this->assertEquals(['surname' => 'Mövsümov'], Arr::add([], 'surname', 'Mövsümov'));
3434
$this->assertEquals(['developer' => ['name' => 'Ferid']], Arr::add([], 'developer.name', 'Ferid'));
35+
$this->assertEquals([1 => 'hAz'], Arr::add([], 1, 'hAz'));
36+
$this->assertEquals([1 => [1 => 'hAz']], Arr::add([], 1.1, 'hAz'));
3537
}
3638

3739
public function testCollapse()
@@ -760,6 +762,9 @@ public function testSet()
760762
$array = ['products' => 'table'];
761763
Arr::set($array, 'products.desk.price', 300);
762764
$this->assertSame(['products' => ['desk' => ['price' => 300]]], $array);
765+
766+
$array = [1 => 'test'];
767+
$this->assertEquals([1 => 'hAz'], Arr::set($array, 1, 'hAz'));
763768
}
764769

765770
public function testShuffleWithSeed()

0 commit comments

Comments
 (0)