Skip to content

Commit 38a526c

Browse files
author
darkdarin
committed
feat: PHP 8.4 support
1 parent 97eb77c commit 38a526c

19 files changed

+41
-46
lines changed

composer.json

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@
1010
}
1111
],
1212
"require": {
13-
"php": "8.1.*|8.2.*|8.3.*",
13+
"php": "8.1.*|8.2.*|8.3.*|8.4.*",
1414
"illuminate/container": "^10.0|^11.0"
1515
},
1616
"require-dev": {
17-
"laravel/pint": "^1.4",
17+
"laravel/pint": "^1.19",
1818
"mockery/mockery": "^1.5",
1919
"phpunit/phpunit": "^9.6",
2020
"roave/security-advisories": "dev-latest",
21-
"vimeo/psalm": "^5.6"
21+
"vimeo/psalm": "^5.26"
2222
},
2323
"autoload": {
2424
"psr-4": {
@@ -33,6 +33,8 @@
3333
"scripts": {
3434
"lint": "pint --test",
3535
"lint-fix": "pint",
36-
"analyze": "psalm --no-cache"
36+
"analyze": "psalm --no-cache",
37+
"pint": "vendor/bin/pint",
38+
"psalm": "vendor/bin/psalm --output-format=phpstorm --no-cache"
3739
}
3840
}

pint.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"preset": "psr12"
2+
"preset": "per"
33
}

src/Contracts/MiddlewareInterface.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@
22

33
namespace Tochka\JsonRpc\Standard\Contracts;
44

5-
interface MiddlewareInterface
6-
{
7-
}
5+
interface MiddlewareInterface {}

src/Contracts/MiddlewareRegistryInterface.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function appendMiddleware(MiddlewareInterface $middleware, ?string $group
3030
public function addMiddlewareAfter(
3131
MiddlewareInterface $middleware,
3232
string $afterMiddleware,
33-
?string $groupName = null
33+
?string $groupName = null,
3434
): void;
3535

3636
/**
@@ -42,6 +42,6 @@ public function addMiddlewareAfter(
4242
public function addMiddlewareBefore(
4343
MiddlewareInterface $middleware,
4444
string $beforeMiddleware,
45-
?string $groupName = null
45+
?string $groupName = null,
4646
): void;
4747
}

src/DTO/JsonRpcError.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function __construct(int $code, string $message, array|object|null $data
3434
public static function from(object|array $value): self
3535
{
3636
if (is_array($value)) {
37-
$value = (object)$value;
37+
$value = (object) $value;
3838
}
3939

4040
$code = isset($value->code) && is_int($value->code)
@@ -59,7 +59,7 @@ public function toArray(): array
5959
{
6060
$result = [
6161
'code' => $this->code,
62-
'message' => $this->message
62+
'message' => $this->message,
6363
];
6464

6565
if ($this->data !== null) {
@@ -76,7 +76,7 @@ public function jsonSerialize(): array
7676
{
7777
$result = [
7878
'code' => $this->code,
79-
'message' => $this->message
79+
'message' => $this->message,
8080
];
8181

8282
if ($this->data !== null) {

src/DTO/JsonRpcRequest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(string $method, array|object|null $params = null, st
3737
public static function from(object|array $value): self
3838
{
3939
if (is_array($value)) {
40-
$value = (object)$value;
40+
$value = (object) $value;
4141
}
4242

4343
if (empty($value->jsonrpc) || $value->jsonrpc !== self::VERSION) {
@@ -63,7 +63,7 @@ public static function from(object|array $value): self
6363
return new self(
6464
$value->method,
6565
$value->params ?? null,
66-
$value->id ?? null
66+
$value->id ?? null,
6767
);
6868
}
6969

@@ -74,7 +74,7 @@ public function toArray(): array
7474
{
7575
$result = [
7676
'jsonrpc' => $this->jsonrpc,
77-
'method' => $this->method
77+
'method' => $this->method,
7878
];
7979

8080
if ($this->params !== null) {
@@ -95,7 +95,7 @@ public function jsonSerialize(): array
9595
{
9696
$result = [
9797
'jsonrpc' => $this->jsonrpc,
98-
'method' => $this->method
98+
'method' => $this->method,
9999
];
100100

101101
if ($this->params !== null) {

src/DTO/JsonRpcResponse.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Illuminate\Contracts\Support\Arrayable;
66
use Illuminate\Contracts\Support\Jsonable;
77
use Tochka\JsonRpc\Standard\Contracts\JsonRpcInterface;
8-
use Tochka\JsonRpc\Standard\Exceptions\InvalidRequestException;
98
use Tochka\JsonRpc\Standard\Exceptions\InvalidResponseException;
109
use Tochka\JsonRpc\Standard\Helpers\PrepareValue;
1110

@@ -40,24 +39,24 @@ public function __construct(string|int|null $id = null, mixed $result = null, Js
4039
public static function from(object|array $value): self
4140
{
4241
if (is_array($value)) {
43-
$value = (object)$value;
42+
$value = (object) $value;
4443
}
4544

4645
if (empty($value->jsonrpc) || $value->jsonrpc !== self::VERSION) {
4746
throw InvalidResponseException::from('jsonrpc', 'Field must be [2.0]');
4847
}
4948

5049
if (empty($value->id)) {
51-
throw InvalidRequestException::from('id', 'Field must be present');
50+
throw InvalidResponseException::from('id', 'Field must be present');
5251
}
5352

5453
if (!is_string($value->id) && !is_int($value->id)) {
55-
throw InvalidRequestException::from('id', 'Field must be of type [string|int]');
54+
throw InvalidResponseException::from('id', 'Field must be of type [string|int]');
5655
}
5756

5857
if (isset($value->error)) {
5958
if (!is_array($value->error) && !is_object($value->error)) {
60-
throw InvalidRequestException::from('error', 'Field must be of type [array|object]');
59+
throw InvalidResponseException::from('error', 'Field must be of type [array|object]');
6160
}
6261

6362
$error = JsonRpcError::from($value->error);
@@ -68,7 +67,7 @@ public static function from(object|array $value): self
6867
return new self(
6968
$value->id,
7069
$value->result ?? null,
71-
$error
70+
$error,
7271
);
7372
}
7473

@@ -79,7 +78,7 @@ public function toArray(): array
7978
{
8079
$result = [
8180
'jsonrpc' => $this->jsonrpc,
82-
'id' => $this->id
81+
'id' => $this->id,
8382
];
8483

8584
if ($this->result !== null) {
@@ -101,7 +100,7 @@ public function jsonSerialize(): array
101100
{
102101
$result = [
103102
'jsonrpc' => $this->jsonrpc,
104-
'id' => $this->id
103+
'id' => $this->id,
105104
];
106105

107106
if ($this->result !== null) {

src/Exceptions/Additional/InvalidParameterException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public static function from(
2424
string $code,
2525
?string $message = null,
2626
array|object|null $meta = null,
27-
?\Throwable $previous = null
27+
?\Throwable $previous = null,
2828
): self {
2929
return new self(new InvalidParameterError($parameterName, $code, $message, $meta), $previous);
3030
}

src/Exceptions/Errors/InternalError.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function toArray(): array
2424
'name' => $this->exception::class,
2525
'code' => $this->exception->getCode(),
2626
'message' => $this->exception->getMessage(),
27-
]
27+
],
2828
];
2929
}
3030
}

src/Exceptions/Errors/InvalidDataError.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public function toArray(): array
2323
{
2424
return [
2525
'field' => $this->field,
26-
'message' => $this->message
26+
'message' => $this->message,
2727
];
2828
}
2929
}

0 commit comments

Comments
 (0)