Remove usage of uniqid

This commit is contained in:
Fabien Potencier
2024-07-01 18:40:39 +02:00
parent cd2f7f2521
commit 2f8219e691
2 changed files with 2 additions and 2 deletions
+1 -1
View File
@@ -188,7 +188,7 @@ abstract class IntegrationTestCase extends TestCase
// avoid using the same PHP class name for different cases
$p = new \ReflectionProperty($twig, 'templateClassPrefix');
$p->setAccessible(true);
$p->setValue($twig, '__TwigTemplate_'.hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', uniqid((string) mt_rand(), true), false).'_');
$p->setValue($twig, '__TwigTemplate_'.hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', random_bytes(32), false).'_');
$deprecations = [];
try {
+1 -1
View File
@@ -23,7 +23,7 @@ class FilesystemTest extends TestCase
protected function setUp(): void
{
$nonce = hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', uniqid((string) mt_rand(), true));
$nonce = hash(\PHP_VERSION_ID < 80100 ? 'sha256' : 'xxh128', random_bytes(32));
$this->classname = '__Twig_Tests_Cache_FilesystemTest_Template_'.$nonce;
$this->directory = sys_get_temp_dir().'/twig-test';
$this->cache = new FilesystemCache($this->directory);