Merge pull request #1543 from Slamdunk/minor/mt-rand

Switch rand() to mt_rand()
main
Jordi Boggiano 12 years ago
commit 3b2accfb58

@ -58,7 +58,7 @@ abstract class ArchiveDownloader extends FileDownloader
} else { } else {
// Rename the content directory to avoid error when moving up // Rename the content directory to avoid error when moving up
// a child folder with the same name // 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); $this->filesystem->rename($contentDir, $temporaryDir);
$contentDir = $temporaryDir; $contentDir = $temporaryDir;

@ -55,7 +55,7 @@ class FileDownloader implements DownloaderInterface
$this->filesystem = $filesystem ?: new Filesystem(); $this->filesystem = $filesystem ?: new Filesystem();
$this->cache = $cache; $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')); $this->cache->gc($config->get('cache-ttl'), $config->get('cache-files-maxsize'));
} }
self::$cacheCollected = true; self::$cacheCollected = true;

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

@ -236,7 +236,7 @@ class LibraryInstallerTest extends TestCase
protected function createPackageMock() protected function createPackageMock()
{ {
return $this->getMockBuilder('Composer\Package\Package') 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(); ->getMock();
} }
} }

@ -95,7 +95,7 @@ class MetapackageInstallerTest extends \PHPUnit_Framework_TestCase
private function createPackageMock() private function createPackageMock()
{ {
return $this->getMockBuilder('Composer\Package\Package') 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(); ->getMock();
} }
} }

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

Loading…
Cancel
Save