File: 0005-Remove-conditional-NoLocaleTranslator.patch

package info (click to toggle)
php-nesbot-carbon 3.10.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 19,132 kB
  • sloc: php: 163,896; xml: 119; makefile: 32; sh: 14
file content (57 lines) | stat: -rw-r--r-- 1,767 bytes parent folder | download
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
55
56
57
From: Robin Gustafsson <robin@rgson.se>
Date: Sat, 1 Nov 2025 23:23:01 +0100
Subject: Remove conditional NoLocaleTranslator

---
 tests/Carbon/Fixtures/NoLocaleTranslator.php | 33 +++++-----------------------
 1 file changed, 6 insertions(+), 27 deletions(-)

diff --git a/tests/Carbon/Fixtures/NoLocaleTranslator.php b/tests/Carbon/Fixtures/NoLocaleTranslator.php
index ee94e17..f8e82f2 100644
--- a/tests/Carbon/Fixtures/NoLocaleTranslator.php
+++ b/tests/Carbon/Fixtures/NoLocaleTranslator.php
@@ -14,38 +14,17 @@ declare(strict_types=1);
 namespace Tests\Carbon\Fixtures;
 
 use Carbon\Exceptions\NotLocaleAwareException;
-use ReflectionMethod;
-use Symfony\Component\Translation;
 use Symfony\Contracts\Translation\TranslatorInterface;
 
-$transMethod = new ReflectionMethod(
-    class_exists(TranslatorInterface::class)
-        ? TranslatorInterface::class
-        : Translation\Translator::class,
-    'trans',
-);
-
-if ($transMethod->hasReturnType()) {
-    class NoLocaleTranslator implements TranslatorInterface
-    {
-        public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
-        {
-            return $id;
-        }
-
-        public function getLocale(): string
-        {
-            throw new NotLocaleAwareException($this);
-        }
-    }
-
-    return;
-}
-
 class NoLocaleTranslator implements TranslatorInterface
 {
-    public function trans($id, array $parameters = [], $domain = null, $locale = null)
+    public function trans(string $id, array $parameters = [], ?string $domain = null, ?string $locale = null): string
     {
         return $id;
     }
+
+    public function getLocale(): string
+    {
+        throw new NotLocaleAwareException($this);
+    }
 }