Skip to content

Commit

Permalink
Fix type of first arg of uniqid
Browse files Browse the repository at this point in the history
  • Loading branch information
fabpot committed Apr 30, 2024
1 parent ad0caee commit b4ec831
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,6 @@ private function isNamedArguments(Node $arguments): bool

private function getVarName(): string
{
return sprintf('__internal_%s', hash('sha256', uniqid(mt_rand(), true), false));
return sprintf('__internal_%s', hash('sha256', uniqid((string) mt_rand(), true), false));
}
}
2 changes: 1 addition & 1 deletion src/Symfony/Component/DomCrawler/Field/FileFormField.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function setValue(?string $value)
$name = $info['basename'];

// copy to a tmp location
$tmp = sys_get_temp_dir().'/'.strtr(substr(base64_encode(hash('sha256', uniqid(mt_rand(), true), true)), 0, 7), '/', '_');
$tmp = sys_get_temp_dir().'/'.strtr(substr(base64_encode(hash('sha256', uniqid((string) mt_rand(), true), true)), 0, 7), '/', '_');
if (\array_key_exists('extension', $info)) {
$tmp .= '.'.$info['extension'];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Filesystem/Filesystem.php
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ public function tempnam(string $dir, string $prefix/* , string $suffix = '' */)
// Loop until we create a valid temp file or have reached 10 attempts
for ($i = 0; $i < 10; ++$i) {
// Create a unique filename
$tmpFile = $dir.'/'.$prefix.uniqid(mt_rand(), true).$suffix;
$tmpFile = $dir.'/'.$prefix.uniqid((string) mt_rand(), true).$suffix;

// Use fopen instead of file_exists as some streams do not support stat
// Use mode 'x+' to atomically check existence and create to avoid a TOCTOU vulnerability
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ protected function beforeDispatch(string $eventName, object $event)
{
switch ($eventName) {
case KernelEvents::REQUEST:
$event->getRequest()->attributes->set('_stopwatch_token', substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
$event->getRequest()->attributes->set('_stopwatch_token', substr(hash('sha256', uniqid((string) mt_rand(), true)), 0, 6));
$this->stopwatch->openSection();
break;
case KernelEvents::VIEW:
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/HttpKernel/Profiler/Profiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public function collect(Request $request, Response $response, ?\Throwable $excep
return null;
}

$profile = new Profile(substr(hash('sha256', uniqid(mt_rand(), true)), 0, 6));
$profile = new Profile(substr(hash('sha256', uniqid((string) mt_rand(), true)), 0, 6));
$profile->setTime(time());
$profile->setUrl($request->getUri());
$profile->setMethod($request->getMethod());
Expand Down

0 comments on commit b4ec831

Please sign in to comment.