mirror of
https://github.com/ramsey/uuid.git
synced 2026-06-14 15:56:48 +03:00
catch ValueError raised by PHP 8 (#352)
This commit is contained in:
@@ -28,8 +28,12 @@ class DefaultNameGenerator implements NameGeneratorInterface
|
||||
/** @psalm-pure */
|
||||
public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
|
||||
{
|
||||
/** @var string|bool $bytes */
|
||||
$bytes = @hash($hashAlgorithm, $ns->getBytes() . $name, true);
|
||||
try {
|
||||
/** @var string|bool $bytes */
|
||||
$bytes = @hash($hashAlgorithm, $ns->getBytes() . $name, true);
|
||||
} catch (\ValueError $e) {
|
||||
$bytes = false; // keep same behavior than PHP 7
|
||||
}
|
||||
|
||||
if ($bytes === false) {
|
||||
throw new NameException(sprintf(
|
||||
|
||||
Reference in New Issue
Block a user