1
|
|
|
<?php |
2
|
|
|
declare(strict_types = 1); |
3
|
|
|
|
4
|
|
|
namespace Innmind\AMQP\Transport\Frame\Value; |
5
|
|
|
|
6
|
|
|
use Innmind\Immutable\{ |
7
|
|
|
Map, |
8
|
|
|
Pair |
9
|
|
|
}; |
10
|
|
|
|
11
|
|
|
final class Symbols |
12
|
|
|
{ |
13
|
|
|
private static $symbols; |
14
|
|
|
private static $classes; |
15
|
|
|
|
16
|
|
|
private function __construct() |
17
|
|
|
{ |
18
|
|
|
} |
19
|
|
|
|
20
|
24 |
|
public static function symbol(string $class): string |
21
|
|
|
{ |
22
|
24 |
|
self::init(); |
23
|
|
|
|
24
|
24 |
|
return self::$classes->get($class); |
|
|
|
|
25
|
|
|
} |
26
|
|
|
|
27
|
|
|
public static function class(string $symbol): string |
|
|
|
|
28
|
|
|
{ |
29
|
|
|
self::init(); |
30
|
|
|
|
31
|
|
|
return self::$symbols->get($symbol); |
|
|
|
|
32
|
|
|
} |
33
|
|
|
|
34
|
24 |
|
private static function init(): void |
35
|
|
|
{ |
36
|
24 |
|
if (!is_null(self::$symbols)) { |
37
|
23 |
|
return; |
38
|
|
|
} |
39
|
|
|
|
40
|
1 |
|
self::$symbols = (new Map('string', 'string')) |
41
|
1 |
|
->put('b', SignedOctet::class) |
|
|
|
|
42
|
1 |
|
->put('B', UnsignedOctet::class) |
|
|
|
|
43
|
1 |
|
->put('U', SignedShortInteger::class) |
|
|
|
|
44
|
1 |
|
->put('u', UnsignedShortInteger::class) |
|
|
|
|
45
|
1 |
|
->put('I', SignedLongInteger::class) |
|
|
|
|
46
|
1 |
|
->put('i', UnsignedLongInteger::class) |
|
|
|
|
47
|
1 |
|
->put('L', SignedLongLongInteger::class) |
|
|
|
|
48
|
1 |
|
->put('l', UnsignedLongLongInteger::class) |
|
|
|
|
49
|
1 |
|
->put('D', Decimal::class) |
|
|
|
|
50
|
1 |
|
->put('T', Timestamp::class) |
|
|
|
|
51
|
1 |
|
->put('V', VoidValue::class) |
|
|
|
|
52
|
1 |
|
->put('t', Bits::class) |
|
|
|
|
53
|
1 |
|
->put('s', ShortString::class) |
|
|
|
|
54
|
1 |
|
->put('S', LongString::class) |
|
|
|
|
55
|
1 |
|
->put('A', Sequence::class) |
|
|
|
|
56
|
1 |
|
->put('F', Table::class); |
|
|
|
|
57
|
1 |
|
self::$classes = self::$symbols->map(static function(string $symbol, string $class): Pair { |
58
|
1 |
|
return new Pair($class, $symbol); |
59
|
1 |
|
}); |
60
|
|
|
} |
61
|
|
|
} |
62
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: