Skip to content

Commit a7462c0

Browse files
committed
fix conflicts
2 parents 8dac049 + cf3eb90 commit a7462c0

File tree

4 files changed

+20
-70
lines changed

4 files changed

+20
-70
lines changed

src/Illuminate/Collections/Arr.php

Lines changed: 16 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -633,32 +633,31 @@ public static function random($array, $number = null, $preserveKeys = false)
633633
}
634634

635635
if (is_null($number)) {
636-
return head(array_slice($array, random_int(0, $count - 1), 1));
636+
return $array[array_rand($array)];
637637
}
638638

639639
if ((int) $number === 0) {
640640
return [];
641641
}
642642

643-
$keys = array_keys($array);
644-
$count = count($keys);
645-
$selected = [];
643+
$keys = array_rand($array, $number);
646644

647-
for ($i = $count - 1; $i >= $count - $number; $i--) {
648-
$j = random_int(0, $i);
645+
$results = [];
649646

650-
if ($preserveKeys) {
651-
$selected[$keys[$j]] = $array[$keys[$j]];
652-
} else {
653-
$selected[] = $array[$keys[$j]];
647+
if ($preserveKeys) {
648+
foreach ((array) $keys as $key) {
649+
$results[$key] = $array[$key];
650+
}
651+
} else {
652+
foreach ((array) $keys as $key) {
653+
$results[] = $array[$key];
654654
}
655-
656-
$keys[$j] = $keys[$i];
657655
}
658656

659-
return $selected;
657+
return $results;
660658
}
661659

660+
662661
/**
663662
* Set an array item to a given value using "dot" notation.
664663
*
@@ -708,29 +707,15 @@ public static function set(&$array, $key, $value)
708707
*/
709708
public static function shuffle($array, $seed = null)
710709
{
711-
if (! is_null($seed)) {
710+
if (is_null($seed)) {
711+
shuffle($array);
712+
} else {
712713
mt_srand($seed);
713714
shuffle($array);
714715
mt_srand();
715-
716-
return $array;
717-
}
718-
719-
if (empty($array)) {
720-
return [];
721-
}
722-
723-
$keys = array_keys($array);
724-
725-
for ($i = count($keys) - 1; $i > 0; $i--) {
726-
$j = random_int(0, $i);
727-
$shuffled[] = $array[$keys[$j]];
728-
$keys[$j] = $keys[$i];
729716
}
730717

731-
$shuffled[] = $array[$keys[0]];
732-
733-
return $shuffled;
718+
return $array;
734719
}
735720

736721
/**

src/Illuminate/Foundation/Application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Application extends Container implements ApplicationContract, CachesConfig
3838
*
3939
* @var string
4040
*/
41-
const VERSION = '10.1.1';
41+
const VERSION = '10.1.2';
4242

4343
/**
4444
* The base path for the Laravel installation.

tests/Support/SupportArrTest.php

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -741,19 +741,6 @@ public function testRandom()
741741
$this->assertCount(2, array_intersect_assoc(['one' => 'foo', 'two' => 'bar', 'three' => 'baz'], $random));
742742
}
743743

744-
public function testRandomIsActuallyRandom()
745-
{
746-
$values = [];
747-
748-
for ($i = 0; $i < 100; $i++) {
749-
$values[] = Arr::random(['foo', 'bar', 'baz']);
750-
}
751-
752-
$this->assertContains('foo', $values);
753-
$this->assertContains('bar', $values);
754-
$this->assertContains('baz', $values);
755-
}
756-
757744
public function testRandomNotIncrementingKeys()
758745
{
759746
$random = Arr::random(['foo' => 'foo', 'bar' => 'bar', 'baz' => 'baz']);
@@ -840,34 +827,10 @@ public function testSet()
840827

841828
public function testShuffleWithSeed()
842829
{
843-
$this->assertSame(
830+
$this->assertEquals(
844831
Arr::shuffle(range(0, 100, 10), 1234),
845832
Arr::shuffle(range(0, 100, 10), 1234)
846833
);
847-
848-
$this->assertNotSame(
849-
range(0, 100, 10),
850-
Arr::shuffle(range(0, 100, 10), 1234)
851-
);
852-
}
853-
854-
public function testShuffle()
855-
{
856-
$source = range('a', 'z'); // alphabetic keys to ensure values are returned
857-
858-
$sameElements = true;
859-
$dontMatch = false;
860-
861-
// Attempt 5x times to prevent random failures
862-
for ($i = 0; $i < 5; $i++) {
863-
$shuffled = Arr::shuffle($source);
864-
865-
$dontMatch = $dontMatch || $source !== $shuffled;
866-
$sameElements = $sameElements && $source === array_values(Arr::sort($shuffled));
867-
}
868-
869-
$this->assertTrue($sameElements, 'Shuffled array should always have the same elements.');
870-
$this->assertTrue($dontMatch, 'Shuffled array should not have the same order.');
871834
}
872835

873836
public function testEmptyShuffle()

tests/View/Blade/BladeEscapedTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ public function testNestedEscapes()
2222
$template = '
2323
@foreach($cols as $col)
2424
@@foreach($issues as $issue_45915)
25+
👋 سلام 👋
2526
@@endforeach
2627
@endforeach';
2728
$compiled = '
2829
<?php $__currentLoopData = $cols; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $col): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
2930
@foreach($issues as $issue_45915)
31+
👋 سلام 👋
3032
@endforeach
3133
<?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>';
3234
$this->assertSame($compiled, $this->compiler->compileString($template));

0 commit comments

Comments
 (0)