Skip to content

Commit 0a422fa

Browse files
authored
task: bump minimum php release to 8.1 (#68)
Signed-off-by: Alan Brault <[email protected]>
1 parent 555ebb0 commit 0a422fa

File tree

6 files changed

+38
-35
lines changed

6 files changed

+38
-35
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
}
1515
],
1616
"require": {
17-
"php": "^8.0"
17+
"php": "^8.1"
1818
},
1919
"require-dev": {
2020
"ext-ctype": "*",

composer.lock

Lines changed: 10 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

psalm.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?xml version="1.0"?>
22
<psalm
33
errorLevel="1"
4+
findUnusedBaselineEntry="true"
5+
findUnusedCode="false"
46
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
57
xmlns="https://getpsalm.org/schema/config"
68
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">

src/Counter.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
*/
1515
final class Counter
1616
{
17-
/**
18-
* @var Counter|null
19-
*/
2017
private static ?Counter $instance = null;
2118

2219
/**
@@ -32,6 +29,11 @@ private function __construct()
3229
$this->value = (int)(random_int(PHP_INT_MIN, PHP_INT_MAX) * 476782367);
3330
}
3431

32+
/**
33+
* Gets the current instance.
34+
*
35+
* @return Counter
36+
*/
3537
public static function getInstance(): Counter
3638
{
3739
if (is_null(self::$instance)) {
@@ -41,6 +43,11 @@ public static function getInstance(): Counter
4143
return self::$instance;
4244
}
4345

46+
/**
47+
* Gets the next value from the current instance.
48+
*
49+
* @return int
50+
*/
4451
public function getNextValue(): int
4552
{
4653
return $this->value++;

src/Cuid2.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,32 +10,26 @@
1010

1111
final class Cuid2 implements JsonSerializable
1212
{
13-
/** @readonly */
14-
private int $counter;
13+
private readonly int $counter;
1514

1615
/**
1716
* @var array<array-key, mixed>
18-
* @readonly
1917
*/
20-
private array $fingerprint;
18+
private readonly array $fingerprint;
2119

2220
/**
2321
* @var int<1, max>
24-
* @readonly
2522
*/
26-
private int $length;
23+
private readonly int $length;
2724

28-
/** @readonly */
29-
private string $prefix;
25+
private readonly string $prefix;
3026

3127
/**
3228
* @var array<array-key, mixed>
33-
* @readonly
3429
*/
35-
private array $random;
30+
private readonly array $random;
3631

37-
/** @readonly */
38-
private int $timestamp;
32+
private readonly int $timestamp;
3933

4034
/**
4135
* Initializes a new instance of Cuid2.

src/Fingerprint.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@
1414
*/
1515
final class Fingerprint
1616
{
17-
/** @var ?Fingerprint */
1817
private static ?Fingerprint $instance = null;
1918

2019
/**
2120
* @var array<array-key, mixed>
22-
* @psalm-readonly-allow-private-mutation
23-
* @readonly
2421
*/
25-
private array $value;
22+
private readonly array $value;
2623

2724
/**
2825
* @throws Exception
@@ -32,6 +29,11 @@ private function __construct()
3229
$this->value = $this->generateFingerprint();
3330
}
3431

32+
/**
33+
* Gets the current instance.
34+
*
35+
* @return Fingerprint
36+
*/
3537
public static function getInstance(): Fingerprint
3638
{
3739
if (is_null(self::$instance)) {
@@ -42,17 +44,16 @@ public static function getInstance(): Fingerprint
4244
}
4345

4446
/**
47+
* Gets the value from the instance.
48+
*
4549
* @return array<array-key, mixed>
4650
*/
4751
public function getValue(): array
4852
{
4953
return $this->value;
5054
}
5155

52-
/**
53-
* @return string|bool
54-
*/
55-
private function getRemoteHostAddr()
56+
private function getRemoteHostAddr(): bool|string
5657
{
5758
$fields = [
5859
'HTTP_X_FORWARDED_FOR',
@@ -73,7 +74,6 @@ private function getRemoteHostAddr()
7374
continue;
7475
}
7576

76-
/** @var string|bool $result */
7777
$result = filter_var($_SERVER[$field], FILTER_VALIDATE_IP);
7878

7979
if (!$result) {

0 commit comments

Comments
 (0)