Skip to content

Commit 7a806bf

Browse files
keradusnicolas-grekas
authored andcommitted
PHP CS Fixer: enable random_api_migration
1 parent 0562b8f commit 7a806bf

File tree

14 files changed

+20
-17
lines changed

14 files changed

+20
-17
lines changed

.php-cs-fixer.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
]),
4747
],
4848
'php_unit_attributes' => true,
49+
'random_api_migration' => true,
4950
// 'static_lambda' => true, // @todo @keradus to fix last issues
5051
])
5152
->setRiskyAllowed(true)

src/Symfony/Component/Cache/Tests/Adapter/ProxyAdapterAndRedisAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static function (CacheItem $item, $expiry) {
5050

5151
$cache = $this->createCachePool(1);
5252
$cache->clear();
53-
$value = rand();
53+
$value = random_int(0, getrandmax());
5454
$item = $cache->getItem('foo');
5555
$setCacheItemExpiry($item, 0);
5656
$cache->save($item->set($value));

src/Symfony/Component/Config/Tests/Resource/DirectoryResourceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public function testResourceDoesNotExist()
6767
{
6868
$this->expectException(\InvalidArgumentException::class);
6969
$this->expectExceptionMessageMatches('/The directory ".*" does not exist./');
70-
new DirectoryResource('/____foo/foobar'.mt_rand(1, 999999));
70+
new DirectoryResource('/____foo/foobar'.random_int(1, 999999));
7171
}
7272

7373
public function testIsFresh()

src/Symfony/Component/Config/Tests/Resource/FileResourceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function testResourceDoesNotExist()
5555
{
5656
$this->expectException(\InvalidArgumentException::class);
5757
$this->expectExceptionMessageMatches('/The file ".*" does not exist./');
58-
new FileResource('/____foo/foobar'.mt_rand(1, 999999));
58+
new FileResource('/____foo/foobar'.random_int(1, 999999));
5959
}
6060

6161
public function testIsFresh()

src/Symfony/Component/Filesystem/Tests/FilesystemTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -662,7 +662,7 @@ public function testChownSymlinkFails()
662662

663663
$this->filesystem->symlink($file, $link);
664664

665-
$this->filesystem->chown($link, 'user'.time().mt_rand(1000, 9999));
665+
$this->filesystem->chown($link, 'user'.time().random_int(1000, 9999));
666666
}
667667

668668
public function testChownLinkFails()
@@ -677,7 +677,7 @@ public function testChownLinkFails()
677677

678678
$this->filesystem->hardlink($file, $link);
679679

680-
$this->filesystem->chown($link, 'user'.time().mt_rand(1000, 9999));
680+
$this->filesystem->chown($link, 'user'.time().random_int(1000, 9999));
681681
}
682682

683683
public function testChownFail()
@@ -688,7 +688,7 @@ public function testChownFail()
688688
$dir = $this->workspace.\DIRECTORY_SEPARATOR.'dir';
689689
mkdir($dir);
690690

691-
$this->filesystem->chown($dir, 'user'.time().mt_rand(1000, 9999));
691+
$this->filesystem->chown($dir, 'user'.time().random_int(1000, 9999));
692692
}
693693

694694
public function testChgrpByName()
@@ -795,7 +795,7 @@ public function testChgrpSymlinkFails()
795795

796796
$this->filesystem->symlink($file, $link);
797797

798-
$this->filesystem->chgrp($link, 'user'.time().mt_rand(1000, 9999));
798+
$this->filesystem->chgrp($link, 'user'.time().random_int(1000, 9999));
799799
}
800800

801801
public function testChgrpLinkFails()
@@ -810,7 +810,7 @@ public function testChgrpLinkFails()
810810

811811
$this->filesystem->hardlink($file, $link);
812812

813-
$this->filesystem->chgrp($link, 'user'.time().mt_rand(1000, 9999));
813+
$this->filesystem->chgrp($link, 'user'.time().random_int(1000, 9999));
814814
}
815815

816816
public function testChgrpFail()
@@ -821,7 +821,7 @@ public function testChgrpFail()
821821
$dir = $this->workspace.\DIRECTORY_SEPARATOR.'dir';
822822
mkdir($dir);
823823

824-
$this->filesystem->chgrp($dir, 'user'.time().mt_rand(1000, 9999));
824+
$this->filesystem->chgrp($dir, 'user'.time().random_int(1000, 9999));
825825
}
826826

827827
public function testRename()

src/Symfony/Component/Form/Tests/Extension/Core/Type/ChoiceTypePerformanceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testSameChoiceFieldCreatedMultipleTimes()
3030
$choices = range(1, 300);
3131

3232
for ($i = 0; $i < 100; ++$i) {
33-
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', mt_rand(1, 400), [
33+
$this->factory->create('Symfony\Component\Form\Extension\Core\Type\ChoiceType', random_int(1, 400), [
3434
'choices' => $choices,
3535
]);
3636
}

src/Symfony/Component/HttpKernel/Profiler/FileProfilerStorage.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ public function write(Profile $profile): bool
189189
], ',', '"', '\\');
190190
fclose($file);
191191

192-
if (1 === mt_rand(1, 10)) {
192+
if (1 === random_int(1, 10)) {
193193
$this->removeExpiredProfiles();
194194
}
195195
}

src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/JsonBundleWriterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class JsonBundleWriterTest extends TestCase
2828
protected function setUp(): void
2929
{
3030
$this->writer = new JsonBundleWriter();
31-
$this->directory = sys_get_temp_dir().'/JsonBundleWriterTest/'.mt_rand(1000, 9999);
31+
$this->directory = sys_get_temp_dir().'/JsonBundleWriterTest/'.random_int(1000, 9999);
3232
$this->filesystem = new Filesystem();
3333

3434
$this->filesystem->mkdir($this->directory);

src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/PhpBundleWriterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PhpBundleWriterTest extends TestCase
2828
protected function setUp(): void
2929
{
3030
$this->writer = new PhpBundleWriter();
31-
$this->directory = sys_get_temp_dir().'/PhpBundleWriterTest/'.mt_rand(1000, 9999);
31+
$this->directory = sys_get_temp_dir().'/PhpBundleWriterTest/'.random_int(1000, 9999);
3232
$this->filesystem = new Filesystem();
3333

3434
$this->filesystem->mkdir($this->directory);

src/Symfony/Component/Intl/Tests/Data/Bundle/Writer/TextBundleWriterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TextBundleWriterTest extends TestCase
2929
protected function setUp(): void
3030
{
3131
$this->writer = new TextBundleWriter();
32-
$this->directory = sys_get_temp_dir().'/TextBundleWriterTest/'.mt_rand(1000, 9999);
32+
$this->directory = sys_get_temp_dir().'/TextBundleWriterTest/'.random_int(1000, 9999);
3333
$this->filesystem = new Filesystem();
3434

3535
$this->filesystem->mkdir($this->directory);

0 commit comments

Comments
 (0)