Skip to content

Commit 5c0648f

Browse files
authored
Merge pull request #18 from bwaidelich/task/switch-to-php-cs-fixer
TASK: Switch to PHP CS Fixer
2 parents ae01ab5 + 78b3d19 commit 5c0648f

24 files changed

+71
-80
lines changed

.php-cs-fixer.dist.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
$finder = (new PhpCsFixer\Finder())
4+
->in(__DIR__);
5+
6+
return (new PhpCsFixer\Config())
7+
->setParallelConfig(PhpCsFixer\Runner\Parallel\ParallelConfigFactory::detect())
8+
->setRules([
9+
'@PER-CS' => true,
10+
'single_quote' => true,
11+
'no_unused_imports' => true,
12+
'ordered_imports' => ['imports_order' => ['class', 'function', 'const']],
13+
'nullable_type_declaration' => ['syntax' => 'union'],
14+
'no_extra_blank_lines' => true,
15+
])
16+
->setFinder($finder);

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"require-dev": {
2828
"roave/security-advisories": "dev-latest",
2929
"phpstan/phpstan": "^2",
30-
"squizlabs/php_codesniffer": "^4.0.x-dev",
30+
"friendsofphp/php-cs-fixer": "^3.88",
3131
"phpunit/phpunit": "^11"
3232
},
3333
"autoload": {
@@ -42,8 +42,8 @@
4242
},
4343
"scripts": {
4444
"test:phpstan": "phpstan",
45-
"test:cs": "phpcs --colors src",
46-
"test:cs:fix": "phpcbf --colors src",
45+
"test:cs": "vendor/bin/php-cs-fixer check",
46+
"test:cs:fix": "vendor/bin/php-cs-fixer fix",
4747
"test:unit": "phpunit tests/Unit",
4848
"test:integration": "phpunit tests/Integration --exclude-group=feature_liveStream --exclude-group=feature_appendConditionWithoutMatchingEvent",
4949
"test": [

phpcs.xml

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

src/EventStore.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ interface EventStore
2222
* @param StreamQuery $query The StreamQuery filter every event has to match
2323
* @param ReadOptions|null $options optional configuration for this interaction ({@see ReadOptions})
2424
*/
25-
public function read(StreamQuery $query, ?ReadOptions $options = null): EventStream;
25+
public function read(StreamQuery $query, ReadOptions|null $options = null): EventStream;
2626

2727
/**
2828
* Commits the specified $events if the specified {@see AppendCondition} is satisfied

src/EventStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,5 @@ interface EventStream extends IteratorAggregate
2020
*/
2121
public function getIterator(): Traversable;
2222

23-
public function first(): ?EventEnvelope;
23+
public function first(): EventEnvelope|null;
2424
}

src/Helpers/InMemoryEventStore.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
namespace Wwwision\DCBEventStore\Helpers;
66

7-
use DateTimeImmutable;
87
use Psr\Clock\ClockInterface;
98
use Wwwision\DCBEventStore\EventStore;
109
use Wwwision\DCBEventStore\Exceptions\ConditionalAppendFailed;
@@ -45,7 +44,7 @@ public static function create(ClockInterface|null $clock = null): self
4544
return new self($clock ?? new SystemClock());
4645
}
4746

48-
public function read(StreamQuery $query, ?ReadOptions $options = null): InMemoryEventStream
47+
public function read(StreamQuery $query, ReadOptions|null $options = null): InMemoryEventStream
4948
{
5049
$options ??= ReadOptions::create();
5150

@@ -113,7 +112,7 @@ public function append(Events|Event $events, AppendCondition $condition): void
113112
$sequenceNumber,
114113
$this->clock->now(),
115114
$event,
116-
)
115+
),
117116
);
118117
$sequenceNumber = $sequenceNumber->next();
119118
}

src/Helpers/InMemoryEventStream.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ final class InMemoryEventStream implements EventStream
2121
*/
2222
private function __construct(
2323
private readonly array $eventEnvelopes,
24-
) {
25-
}
24+
) {}
2625

2726
public static function create(EventEnvelope ...$events): self
2827
{
@@ -41,7 +40,7 @@ public function getIterator(): Traversable
4140
}
4241
}
4342

44-
public function first(): ?EventEnvelope
43+
public function first(): EventEnvelope|null
4544
{
4645
return $this->eventEnvelopes[array_key_first($this->eventEnvelopes)] ?? null;
4746
}

src/Types/AppendCondition.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ final class AppendCondition
1515
public function __construct(
1616
public readonly StreamQuery $query,
1717
public readonly ExpectedHighestSequenceNumber $expectedHighestSequenceNumber,
18-
) {
19-
}
18+
) {}
2019

2120
public static function noConstraints(): self
2221
{

src/Types/Event.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ private function __construct(
1717
public readonly EventData $data, // opaque, no size limit?
1818
public readonly Tags $tags,
1919
public readonly EventMetadata $metadata,
20-
) {
21-
}
20+
) {}
2221

2322
/**
2423
* @param EventData|array<mixed>|string $data

src/Types/EventData.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ final class EventData implements JsonSerializable
1616
{
1717
private function __construct(
1818
public readonly string $value,
19-
) {
20-
}
19+
) {}
2120

2221
public static function fromString(string $value): self
2322
{

0 commit comments

Comments
 (0)