Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/backward-compatibility-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
fetch-depth: 0

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
extensions: pdo_sqlite

- name: "Checkout base"
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
ref: ${{ github.base_ref }}

Expand All @@ -58,7 +58,7 @@ jobs:
run: "vendor/bin/phpbench run tests/Benchmark --progress=none --report=default --tag=base"

- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
clean: false

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/coding-standard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
Expand Down
48 changes: 48 additions & 0 deletions .github/workflows/docs-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# https://help.github.com/en/categories/automating-your-workflow-with-github-actions

name: "Check Docs"

on:
pull_request:
push:
branches:
- "[0-9]+.[0-9]+.x"

jobs:
checkdocs:
name: "Check Docs"

runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
dependencies:
- "locked"
php-version:
- "8.4"
operating-system:
- "ubuntu-latest"

steps:
- name: "Checkout"
uses: actions/checkout@v7

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
with:
coverage: none
php-version: "${{ matrix.php-version }}"
ini-values: memory_limit=-1, opcache.enable_cli=1

- uses: ramsey/composer-install@4.0.0
with:
dependency-versions: ${{ matrix.dependencies }}

- name: "extract php code"
run: "bin/docs-extract-php-code"

- name: "lint php"
run: "php -l docs_php/*.php"

- name: "docs code style"
run: "vendor/bin/phpcbf docs_php --exclude=SlevomatCodingStandard.TypeHints.DeclareStrictTypes"
8 changes: 4 additions & 4 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
Expand Down Expand Up @@ -103,7 +103,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
Expand Down Expand Up @@ -157,7 +157,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mutation-tests-diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7
with:
fetch-depth: 0

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mutation-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/phpstan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: "Release"
uses: "laminas/automatic-releases@v1"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v6
uses: actions/checkout@v7

- name: "Install PHP"
uses: "shivammathur/setup-php@2.37.2"
Expand Down
11 changes: 11 additions & 0 deletions bin/docs-extract-php-code
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\Node\Block\FencedCode;
use League\CommonMark\Extension\FrontMatter\Data\FrontMatterDataParserInterface;
use League\CommonMark\Extension\FrontMatter\FrontMatterExtension;
use League\CommonMark\Node\Query;
use League\CommonMark\Parser\MarkdownParser;
use Wnx\CommonmarkMarkdownRenderer\MarkdownRendererExtension;
Expand All @@ -11,6 +13,15 @@ require __DIR__ . '/../vendor/autoload.php';

$environment = new Environment([]);
$environment->addExtension(new MarkdownRendererExtension());
$environment->addExtension(new FrontMatterExtension(
// keep the raw YAML string so it round-trips byte-identically
new class implements FrontMatterDataParserInterface {
public function parse(string $frontMatter): string
{
return $frontMatter;
}
},
));

$parser = new MarkdownParser($environment);

Expand Down
21 changes: 20 additions & 1 deletion bin/docs-inject-php-code
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@

use League\CommonMark\Environment\Environment;
use League\CommonMark\Extension\CommonMark\Node\Block\FencedCode;
use League\CommonMark\Extension\FrontMatter\Data\FrontMatterDataParserInterface;
use League\CommonMark\Extension\FrontMatter\FrontMatterExtension;
use League\CommonMark\Extension\FrontMatter\Output\RenderedContentWithFrontMatter;
use League\CommonMark\Node\Query;
use League\CommonMark\Parser\MarkdownParser;
use Wnx\CommonmarkMarkdownRenderer\MarkdownRendererExtension;
Expand All @@ -14,6 +17,15 @@ require __DIR__ . '/../vendor/autoload.php';

$environment = new Environment([]);
$environment->addExtension(new MarkdownRendererExtension());
$environment->addExtension(new FrontMatterExtension(
// keep the raw YAML string so it round-trips byte-identically
new class implements FrontMatterDataParserInterface {
public function parse(string $frontMatter): string
{
return $frontMatter;
}
},
));

$parser = new MarkdownParser($environment);
$markdownRenderer = new MarkdownRenderer($environment);
Expand Down Expand Up @@ -62,7 +74,14 @@ foreach ($finder as $file) {
$node->setLiteral(trim($code));
}

file_put_contents($file->getPathname(), $markdownRenderer->renderDocument($document));
$rendered = $markdownRenderer->renderDocument($document);
$output = $rendered->getContent();

if ($rendered instanceof RenderedContentWithFrontMatter) {
$output = $rendered->getFrontMatter() . "---\n" . $output;
}

file_put_contents($file->getPathname(), $output);
}

if (file_exists($targetDir)) {
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ services:
- MYSQL_DATABASE=eventstore
ports:
- 3306:3306

mariadb:
image: mariadb:12
environment:
- MYSQL_ALLOW_EMPTY_PASSWORD="yes"
- MYSQL_DATABASE=eventstore
ports:
- 3307:3306
22 changes: 6 additions & 16 deletions docs/UPGRADE-4.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@ final class HotelProjector
// ...
}
```

If you still need the subscriber id elsewhere, read it from the metadata instead:

```php
Expand All @@ -181,7 +180,6 @@ use Patchlevel\EventSourcing\Metadata\Subscriber\AttributeSubscriberMetadataFact
$metadata = (new AttributeSubscriberMetadataFactory())->metadata($subscriber::class);
$subscriberId = $metadata->id;
```

### SubscriberAccessor and RealSubscriberAccessor

The `Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberAccessor` and
Expand Down Expand Up @@ -228,7 +226,6 @@ final class CustomResolver implements ArgumentResolver
// ... support()
}
```

After:

```php
Expand All @@ -242,7 +239,6 @@ final class CustomResolver implements ArgumentResolver
// ... support()
}
```

### Custom ArgumentResolver registration

Custom argument resolvers are no longer passed to the `MetadataSubscriberAccessorRepository`.
Expand All @@ -262,7 +258,6 @@ $engine = new DefaultSubscriptionEngine(
$subscriberRepository,
);
```

After:

```php
Expand All @@ -277,7 +272,6 @@ $engine = new DefaultSubscriptionEngine(
argumentResolvers: [new MyResolver()],
);
```

### Batchable Subscriber

The `Patchlevel\EventSourcing\Subscription\Subscriber\BatchableSubscriber` interface has been removed.
Expand Down Expand Up @@ -329,15 +323,13 @@ final class MigrationSubscriber implements BatchableSubscriber
}
}
```

After:

```php
use Patchlevel\EventSourcing\Attribute\BatchState;
use Patchlevel\EventSourcing\Attribute\BatchBegin;
use Patchlevel\EventSourcing\Attribute\BatchFlush;
use Patchlevel\EventSourcing\Attribute\BatchRollback;
use Patchlevel\EventSourcing\Attribute\BatchShouldFlush;
use Patchlevel\EventSourcing\Attribute\BatchState;

final class MigrationBatch
{
Expand All @@ -355,8 +347,11 @@ final class MigrationSubscriber
}

#[Subscribe(NameChanged::class)]
public function handleNameChanged(NameChanged $event, #[BatchState] MigrationBatch $batch): void
{
public function handleNameChanged(
NameChanged $event,
#[BatchState]
MigrationBatch $batch,
): void {
$batch->nameChanged[$event->userId] = $event->name;
}

Expand All @@ -372,7 +367,6 @@ final class MigrationSubscriber
}
}
```

### Parallel subscription processing

The subscription engine now processes one subscription at a time instead of driving a single shared
Expand All @@ -391,7 +385,6 @@ separate `LockableSubscriptionStore` interface has been removed. Every custom st
both:

```php
use Closure;
use Patchlevel\EventSourcing\Subscription\Store\SubscriptionCriteria;
use Patchlevel\EventSourcing\Subscription\Subscription;

Expand All @@ -415,7 +408,6 @@ interface SubscriptionStore
public function inLock(Closure $closure): mixed;
}
```

`find()` no longer locks the matched rows: it is now a plain, unlocked snapshot read. The locking
happens per subscription inside `claim()`.

Expand Down Expand Up @@ -496,15 +488,13 @@ use Patchlevel\EventSourcing\Message\Pipe;

$messages = (new Pipe($messages, $translator))->toArray();
```

after:

```php
use Patchlevel\EventSourcing\Message\Stream;

$messages = (new Stream($messages))->transform($translator)->toList();
```

## Message

### AggregateHeader
Expand Down
Loading
Loading