File tree Expand file tree Collapse file tree 6 files changed +38
-35
lines changed Expand file tree Collapse file tree 6 files changed +38
-35
lines changed Original file line number Diff line number Diff line change 14
14
}
15
15
],
16
16
"require" : {
17
- "php" : " ^8.0 "
17
+ "php" : " ^8.1 "
18
18
},
19
19
"require-dev" : {
20
20
"ext-ctype" : " *" ,
Original file line number Diff line number Diff line change 1
1
<?xml version =" 1.0" ?>
2
2
<psalm
3
3
errorLevel =" 1"
4
+ findUnusedBaselineEntry =" true"
5
+ findUnusedCode =" false"
4
6
xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
5
7
xmlns =" https://getpsalm.org/schema/config"
6
8
xsi : schemaLocation =" https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" >
Original file line number Diff line number Diff line change 14
14
*/
15
15
final class Counter
16
16
{
17
- /**
18
- * @var Counter|null
19
- */
20
17
private static ?Counter $ instance = null ;
21
18
22
19
/**
@@ -32,6 +29,11 @@ private function __construct()
32
29
$ this ->value = (int )(random_int (PHP_INT_MIN , PHP_INT_MAX ) * 476782367 );
33
30
}
34
31
32
+ /**
33
+ * Gets the current instance.
34
+ *
35
+ * @return Counter
36
+ */
35
37
public static function getInstance (): Counter
36
38
{
37
39
if (is_null (self ::$ instance )) {
@@ -41,6 +43,11 @@ public static function getInstance(): Counter
41
43
return self ::$ instance ;
42
44
}
43
45
46
+ /**
47
+ * Gets the next value from the current instance.
48
+ *
49
+ * @return int
50
+ */
44
51
public function getNextValue (): int
45
52
{
46
53
return $ this ->value ++;
Original file line number Diff line number Diff line change 10
10
11
11
final class Cuid2 implements JsonSerializable
12
12
{
13
- /** @readonly */
14
- private int $ counter ;
13
+ private readonly int $ counter ;
15
14
16
15
/**
17
16
* @var array<array-key, mixed>
18
- * @readonly
19
17
*/
20
- private array $ fingerprint ;
18
+ private readonly array $ fingerprint ;
21
19
22
20
/**
23
21
* @var int<1, max>
24
- * @readonly
25
22
*/
26
- private int $ length ;
23
+ private readonly int $ length ;
27
24
28
- /** @readonly */
29
- private string $ prefix ;
25
+ private readonly string $ prefix ;
30
26
31
27
/**
32
28
* @var array<array-key, mixed>
33
- * @readonly
34
29
*/
35
- private array $ random ;
30
+ private readonly array $ random ;
36
31
37
- /** @readonly */
38
- private int $ timestamp ;
32
+ private readonly int $ timestamp ;
39
33
40
34
/**
41
35
* Initializes a new instance of Cuid2.
Original file line number Diff line number Diff line change 14
14
*/
15
15
final class Fingerprint
16
16
{
17
- /** @var ?Fingerprint */
18
17
private static ?Fingerprint $ instance = null ;
19
18
20
19
/**
21
20
* @var array<array-key, mixed>
22
- * @psalm-readonly-allow-private-mutation
23
- * @readonly
24
21
*/
25
- private array $ value ;
22
+ private readonly array $ value ;
26
23
27
24
/**
28
25
* @throws Exception
@@ -32,6 +29,11 @@ private function __construct()
32
29
$ this ->value = $ this ->generateFingerprint ();
33
30
}
34
31
32
+ /**
33
+ * Gets the current instance.
34
+ *
35
+ * @return Fingerprint
36
+ */
35
37
public static function getInstance (): Fingerprint
36
38
{
37
39
if (is_null (self ::$ instance )) {
@@ -42,17 +44,16 @@ public static function getInstance(): Fingerprint
42
44
}
43
45
44
46
/**
47
+ * Gets the value from the instance.
48
+ *
45
49
* @return array<array-key, mixed>
46
50
*/
47
51
public function getValue (): array
48
52
{
49
53
return $ this ->value ;
50
54
}
51
55
52
- /**
53
- * @return string|bool
54
- */
55
- private function getRemoteHostAddr ()
56
+ private function getRemoteHostAddr (): bool |string
56
57
{
57
58
$ fields = [
58
59
'HTTP_X_FORWARDED_FOR ' ,
@@ -73,7 +74,6 @@ private function getRemoteHostAddr()
73
74
continue ;
74
75
}
75
76
76
- /** @var string|bool $result */
77
77
$ result = filter_var ($ _SERVER [$ field ], FILTER_VALIDATE_IP );
78
78
79
79
if (!$ result ) {
You can’t perform that action at this time.
0 commit comments