diff --git a/src/Composer/Downloader/ArchiveDownloader.php b/src/Composer/Downloader/ArchiveDownloader.php index b8fc32c7d..d85116c2e 100644 --- a/src/Composer/Downloader/ArchiveDownloader.php +++ b/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; diff --git a/src/Composer/Downloader/FileDownloader.php b/src/Composer/Downloader/FileDownloader.php index fe2aa1abe..d05aa6ad2 100644 --- a/src/Composer/Downloader/FileDownloader.php +++ b/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; diff --git a/tests/Composer/Test/Downloader/FileDownloaderTest.php b/tests/Composer/Test/Downloader/FileDownloaderTest.php index 83a1c7b5f..99dcaab18 100644 --- a/tests/Composer/Test/Downloader/FileDownloaderTest.php +++ b/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(); diff --git a/tests/Composer/Test/Installer/LibraryInstallerTest.php b/tests/Composer/Test/Installer/LibraryInstallerTest.php index c76052e22..1f6d4cbe8 100644 --- a/tests/Composer/Test/Installer/LibraryInstallerTest.php +++ b/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(); } } diff --git a/tests/Composer/Test/Installer/MetapackageInstallerTest.php b/tests/Composer/Test/Installer/MetapackageInstallerTest.php index a590274df..64316300d 100644 --- a/tests/Composer/Test/Installer/MetapackageInstallerTest.php +++ b/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(); } } diff --git a/tests/Composer/Test/Repository/VcsRepositoryTest.php b/tests/Composer/Test/Repository/VcsRepositoryTest.php index c79b2807b..5c253d522 100644 --- a/tests/Composer/Test/Repository/VcsRepositoryTest.php +++ b/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')) {