Skip to content

Commit 7491939

Browse files
authored
Merge pull request #12 from php-etl/feature/update-contracts
Fixed phpstan errors
2 parents 8f938c9 + 60f2ede commit 7491939

File tree

11 files changed

+47
-66
lines changed

11 files changed

+47
-66
lines changed

.github/workflows/phpstan-5.yaml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/phpstan-6.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PHPStan level 6
22
on: push
33
jobs:
4-
phpstan:
4+
phpstan-6:
55
runs-on: ubuntu-latest
66
steps:
77
- uses: actions/checkout@v3

.github/workflows/phpstan-7.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PHPStan level 7
22
on: push
33
jobs:
4-
phpstan:
4+
phpstan-7:
55
runs-on: ubuntu-latest
66
steps:
77
- uses: actions/checkout@v3

.github/workflows/phpstan-8.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: PHPStan level 8
22
on: push
33
jobs:
4-
phpstan:
4+
phpstan-8:
55
runs-on: ubuntu-latest
66
steps:
77
- uses: actions/checkout@v3

.github/workflows/quality.yaml

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Quality (PHPStan lvl 4)
1+
name: Quality (PHPStan lvl 5)
22
on: push
33
jobs:
44
cs-fixer:
@@ -17,20 +17,19 @@ jobs:
1717
phpstan:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- uses: actions/checkout@v3
21-
- uses: actions/cache@v3
22-
with:
23-
path: '**/vendor'
24-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
25-
restore-keys: |
26-
${{ runner.os }}-composer-
27-
- uses: php-actions/composer@v6
28-
with:
29-
args: --prefer-dist
30-
php_version: '8.2'
31-
32-
- name: PHPStan
33-
uses: php-actions/phpstan@v3
34-
with:
35-
path: src/
36-
level: 4
20+
- uses: actions/checkout@v3
21+
- uses: actions/cache@v3
22+
with:
23+
path: '**/vendor'
24+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
25+
restore-keys: |
26+
${{ runner.os }}-composer-
27+
- uses: php-actions/composer@v6
28+
with:
29+
args: --prefer-dist
30+
php_version: '8.2'
31+
- name: PHPStan
32+
uses: php-actions/phpstan@v3
33+
with:
34+
path: src/
35+
level: 5

.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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Bunny\Channel;
88
use Bunny\Client;
99
use Kiboko\Component\Bucket\AcceptanceResultBucket;
10+
use Kiboko\Component\Bucket\EmptyResultBucket;
1011
use Kiboko\Contract\Pipeline\LoaderInterface;
1112

1213
final readonly class Loader implements LoaderInterface
@@ -71,11 +72,12 @@ public static function withAuthentication(
7172

7273
public function load(): \Generator
7374
{
74-
$line = yield;
75+
$line = yield new EmptyResultBucket();
7576

77+
// @phpstan-ignore-next-line
7678
while (true) {
7779
$this->channel->publish(
78-
json_encode($line, \JSON_THROW_ON_ERROR),
80+
\json_encode($line, \JSON_THROW_ON_ERROR),
7981
[
8082
'content-type' => 'application/json',
8183
],

src/Rejection.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,12 @@ 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,
@@ -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, object|array $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, object|array $rejection, ?\Throw
8793
);
8894
}
8995

90-
public function rejectWithReason(StepCodeInterface $step, object|array $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: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Kiboko\Component\Flow\RabbitMQ;
66

7-
use Kiboko\Contract\Pipeline\StepCodeInterface;
87
use Kiboko\Contract\Pipeline\StepStateInterface;
98

109
final class State implements StepStateInterface
@@ -17,8 +16,7 @@ public function __construct(
1716
private readonly StateManager $manager,
1817
private readonly string $stepCode,
1918
private readonly string $stepLabel,
20-
) {
21-
}
19+
) {}
2220

2321
public function accept(int $count = 1): void
2422
{
@@ -46,7 +44,7 @@ public function toArray(): array
4644
return [
4745
'code' => $this->stepCode,
4846
'label' => $this->stepLabel ?: $this->stepCode,
49-
'metrics' => iterator_to_array($this->walkMetrics()),
47+
'metrics' => \iterator_to_array($this->walkMetrics()),
5048
];
5149
}
5250

0 commit comments

Comments
 (0)