summaryrefslogtreecommitdiffstats
path: root/352.patch
blob: b7ba70d4f914b28c0f721b443888405a8abebefd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
From 2a39b0a67413e902274b09f640c6b68ffbd199fa Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Thu, 29 Oct 2020 16:34:55 +0100
Subject: [PATCH 1/2] catch ValueError raised by PHP 8

---
 src/Generator/DefaultNameGenerator.php | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/Generator/DefaultNameGenerator.php b/src/Generator/DefaultNameGenerator.php
index 270e8fbe..be552b91 100644
--- a/src/Generator/DefaultNameGenerator.php
+++ b/src/Generator/DefaultNameGenerator.php
@@ -29,7 +29,11 @@ class DefaultNameGenerator implements NameGeneratorInterface
     public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
     {
         /** @var string|bool $bytes */
-        $bytes = @hash($hashAlgorithm, $ns->getBytes() . $name, true);
+        try {
+            $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(

From 3a488f24e05e711809f61626aeb8740d53e56feb Mon Sep 17 00:00:00 2001
From: Remi Collet <remi@remirepo.net>
Date: Thu, 29 Oct 2020 16:40:08 +0100
Subject: [PATCH 2/2] CS

---
 src/Generator/DefaultNameGenerator.php | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/Generator/DefaultNameGenerator.php b/src/Generator/DefaultNameGenerator.php
index be552b91..1c0b0048 100644
--- a/src/Generator/DefaultNameGenerator.php
+++ b/src/Generator/DefaultNameGenerator.php
@@ -28,11 +28,11 @@ class DefaultNameGenerator implements NameGeneratorInterface
     /** @psalm-pure */
     public function generate(UuidInterface $ns, string $name, string $hashAlgorithm): string
     {
-        /** @var string|bool $bytes */
         try {
+            /** @var string|bool $bytes */
             $bytes = @hash($hashAlgorithm, $ns->getBytes() . $name, true);
         } catch (\ValueError $e) {
-            $bytes = false; // keep same behavior than PHP 7 */
+            $bytes = false; // keep same behavior than PHP 7
         }
 
         if ($bytes === false) {