Skip to content

Commit fb0a3ec

Browse files
committed
Updated php-cs-fixer rules
1 parent 5c222c0 commit fb0a3ec

File tree

6 files changed

+34
-29
lines changed

6 files changed

+34
-29
lines changed

.php-cs-fixer.dist.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,12 @@
2424
'php_unit_construct' => true,
2525
'no_useless_sprintf' => true,
2626
'no_homoglyph_names' => true,
27-
'native_function_invocation' => true,
28-
'native_constant_invocation' => true,
27+
'native_function_invocation' => [
28+
'include' => ['@all'],
29+
],
30+
'native_constant_invocation' => [
31+
'include' => ['@all'],
32+
],
2933
'modernize_types_casting' => true,
3034
'logical_operators' => true,
3135
'is_null' => true,
@@ -35,6 +39,7 @@
3539
'ereg_to_preg' => true,
3640
'dir_constant' => true,
3741
'method_chaining_indentation' => false,
42+
'nullable_type_declaration_for_default_null_value' => true
3843
])
3944
->setFinder($finder)
4045
->setCacheFile('.php-cs-fixer.cache') // forward compatibility with 3.x line

src/Extractor.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public static function withoutAuthentication(
3232
string $host,
3333
string $vhost,
3434
string $topic,
35-
int $port = null,
35+
?int $port = null,
3636
): self {
3737
$connection = new Client([
3838
'host' => $host,
@@ -52,7 +52,7 @@ public static function withAuthentication(
5252
string $topic,
5353
?string $user,
5454
?string $password,
55-
int $port = null,
55+
?int $port = null,
5656
): self {
5757
$connection = new Client([
5858
'host' => $host,
@@ -75,7 +75,7 @@ public function extract(): iterable
7575
}
7676
$this->channel->ack($message);
7777

78-
yield new AcceptanceResultBucket(json_decode($message->content, true, 512, \JSON_THROW_ON_ERROR));
78+
yield new AcceptanceResultBucket(\json_decode($message->content, true, 512, \JSON_THROW_ON_ERROR));
7979
}
8080
}
8181
}

src/Loader.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ public static function withoutAuthentication(
3434
string $host,
3535
string $vhost,
3636
string $topic,
37-
string $exchange = null,
38-
int $port = null,
37+
?string $exchange = null,
38+
?int $port = null,
3939
): self {
4040
$connection = new Client([
4141
'host' => $host,
@@ -55,8 +55,8 @@ public static function withAuthentication(
5555
string $topic,
5656
?string $user,
5757
?string $password,
58-
string $exchange = null,
59-
int $port = null,
58+
?string $exchange = null,
59+
?int $port = null,
6060
): self {
6161
$connection = new Client([
6262
'host' => $host,
@@ -74,10 +74,10 @@ public function load(): \Generator
7474
{
7575
$line = new EmptyResultBucket();
7676

77-
/* @phpstan-ignore-next-line */
77+
// @phpstan-ignore-next-line
7878
while (true) {
7979
$this->channel->publish(
80-
json_encode($line, \JSON_THROW_ON_ERROR),
80+
\json_encode($line, \JSON_THROW_ON_ERROR),
8181
[
8282
'content-type' => 'application/json',
8383
],

src/Rejection.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,19 @@ public function __construct(
2929
);
3030
}
3131

32+
public function teardown(): void
33+
{
34+
$this->channel->close();
35+
$this->connection->stop();
36+
}
37+
3238
public static function withoutAuthentication(
3339
string $stepUuid,
3440
string $host,
3541
string $vhost,
3642
string $topic,
37-
string $exchange = null,
38-
int $port = null,
43+
?string $exchange = null,
44+
?int $port = null,
3945
): self {
4046
$connection = new Client([
4147
'host' => $host,
@@ -56,8 +62,8 @@ public static function withAuthentication(
5662
string $topic,
5763
?string $user,
5864
?string $password,
59-
string $exchange = null,
60-
int $port = null,
65+
?string $exchange = null,
66+
?int $port = null,
6167
): self {
6268
$connection = new Client([
6369
'host' => $host,
@@ -71,10 +77,10 @@ public static function withAuthentication(
7177
return new self($connection, stepUuid: $stepUuid, topic: $topic, exchange: $exchange);
7278
}
7379

74-
public function reject(StepCodeInterface $step, array|object $rejection, \Throwable $exception = null): void
80+
public function reject(StepCodeInterface $step, array|object $rejection, ?\Throwable $exception = null): void
7581
{
7682
$this->channel->publish(
77-
json_encode([
83+
\json_encode([
7884
'item' => $rejection,
7985
'exception' => $exception,
8086
'step' => $this->stepUuid,
@@ -87,10 +93,10 @@ public function reject(StepCodeInterface $step, array|object $rejection, \Throwa
8793
);
8894
}
8995

90-
public function rejectWithReason(StepCodeInterface $step, array|object $rejection, string $reason, \Throwable $exception = null): void
96+
public function rejectWithReason(StepCodeInterface $step, array|object $rejection, string $reason, ?\Throwable $exception = null): void
9197
{
9298
$this->channel->publish(
93-
json_encode([
99+
\json_encode([
94100
'item' => $rejection,
95101
'exception' => $exception,
96102
'step' => $this->stepUuid,
@@ -113,10 +119,4 @@ public function initialize(): void
113119
autoDelete: true,
114120
);
115121
}
116-
117-
public function teardown(): void
118-
{
119-
$this->channel->close();
120-
$this->connection->stop();
121-
}
122122
}

src/State.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function toArray(): array
4444
return [
4545
'code' => $this->stepCode,
4646
'label' => $this->stepLabel ?: $this->stepCode,
47-
'metrics' => iterator_to_array($this->walkMetrics()),
47+
'metrics' => \iterator_to_array($this->walkMetrics()),
4848
];
4949
}
5050

src/StateManager.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,11 @@ private function sendUpdate(): void
7171
$date = new \DateTimeImmutable();
7272

7373
$this->channel->publish(
74-
json_encode([
74+
\json_encode([
7575
'messageNumber' => ++$this->messageCount,
76-
'id' => uuid_create(UUID_TYPE_RANDOM),
76+
'id' => \uuid_create(UUID_TYPE_RANDOM),
7777
'date' => ['date' => $date->format('c'), 'tz' => $date->getTimezone()->getName()],
78-
'stepsUpdates' => array_map(fn (State $step) => $step->toArray(), $this->steps),
78+
'stepsUpdates' => \array_map(fn (State $step) => $step->toArray(), $this->steps),
7979
], \JSON_THROW_ON_ERROR),
8080
[
8181
'content-type' => 'application/json',

0 commit comments

Comments
 (0)