Pārlūkot izejas kodu

Switched rand() to mt_rand()

Filippo Tessarotto 12 gadi atpakaļ
vecāks
revīzija
470adc47df

+ 1 - 1
src/Composer/Downloader/ArchiveDownloader.php

@@ -58,7 +58,7 @@ abstract class ArchiveDownloader extends FileDownloader
                 } else {
                     // Rename the content directory to avoid error when moving up
                     // a child folder with the same name
-                    $temporaryDir = sys_get_temp_dir().'/'.md5(time().rand());
+                    $temporaryDir = sys_get_temp_dir().'/'.md5(time().mt_rand());
                     $this->filesystem->rename($contentDir, $temporaryDir);
                     $contentDir = $temporaryDir;
 

+ 1 - 1
src/Composer/Downloader/FileDownloader.php

@@ -55,7 +55,7 @@ class FileDownloader implements DownloaderInterface
         $this->filesystem = $filesystem ?: new Filesystem();
         $this->cache = $cache;
 
-        if ($this->cache && !self::$cacheCollected && !rand(0, 50)) {
+        if ($this->cache && !self::$cacheCollected && !mt_rand(0, 50)) {
             $this->cache->gc($config->get('cache-ttl'), $config->get('cache-files-maxsize'));
         }
         self::$cacheCollected = true;

+ 2 - 2
tests/Composer/Test/Downloader/FileDownloaderTest.php

@@ -91,7 +91,7 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase
         ;
 
         do {
-            $path = sys_get_temp_dir().'/'.md5(time().rand());
+            $path = sys_get_temp_dir().'/'.md5(time().mt_rand());
         } while (file_exists($path));
 
         $ioMock = $this->getMock('Composer\IO\IOInterface');
@@ -136,7 +136,7 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase
         ;
 
         do {
-            $path = sys_get_temp_dir().'/'.md5(time().rand());
+            $path = sys_get_temp_dir().'/'.md5(time().mt_rand());
         } while (file_exists($path));
 
         $downloader = $this->getDownloader();

+ 1 - 1
tests/Composer/Test/Installer/LibraryInstallerTest.php

@@ -236,7 +236,7 @@ class LibraryInstallerTest extends TestCase
     protected function createPackageMock()
     {
         return $this->getMockBuilder('Composer\Package\Package')
-            ->setConstructorArgs(array(md5(rand()), '1.0.0.0', '1.0.0'))
+            ->setConstructorArgs(array(md5(mt_rand()), '1.0.0.0', '1.0.0'))
             ->getMock();
     }
 }

+ 1 - 1
tests/Composer/Test/Installer/MetapackageInstallerTest.php

@@ -95,7 +95,7 @@ class MetapackageInstallerTest extends \PHPUnit_Framework_TestCase
     private function createPackageMock()
     {
         return $this->getMockBuilder('Composer\Package\Package')
-            ->setConstructorArgs(array(md5(rand()), '1.0.0.0', '1.0.0'))
+            ->setConstructorArgs(array(md5(mt_rand()), '1.0.0.0', '1.0.0'))
             ->getMock();
     }
 }

+ 1 - 1
tests/Composer/Test/Repository/VcsRepositoryTest.php

@@ -31,7 +31,7 @@ class VcsRepositoryTest extends \PHPUnit_Framework_TestCase
     protected function initialize()
     {
         $oldCwd = getcwd();
-        self::$gitRepo = sys_get_temp_dir() . '/composer-git-'.rand().'/';
+        self::$gitRepo = sys_get_temp_dir() . '/composer-git-'.mt_rand().'/';
 
         $locator = new ExecutableFinder();
         if (!$locator->find('git')) {