Skip to content

Commit

Permalink
Merge pull request #248 from patchlevel/upgrade-php-8.1
Browse files Browse the repository at this point in the history
bump php versio to 8.1
  • Loading branch information
DanielBadura authored May 9, 2022
2 parents 74dea00 + ea01210 commit 36b1592
Show file tree
Hide file tree
Showing 17 changed files with 79 additions and 114 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/unit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,16 @@ jobs:
- "lowest"
- "highest"
php-version:
- "8.0"
- "8.1"
operating-system:
- "ubuntu-latest"
- "windows-latest"
include:
- dependencies: "locked"
php-version: "8.0"
php-version: "8.1"
operating-system: "ubuntu-latest"
- dependencies: "locked"
php-version: "8.0"
php-version: "8.1"
operating-system: "windows-latest"

steps:
Expand Down
6 changes: 3 additions & 3 deletions baseline.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="4.23.0@f1fe6ff483bf325c803df9f510d09a03fd796f88">
<file src="src/EventBus/Message.php">
<PropertyTypeCoercion occurrences="1">
<code>$new-&gt;headers</code>
</PropertyTypeCoercion>
<ArgumentTypeCoercion occurrences="1">
<code>[$name =&gt; $value] + $this-&gt;headers</code>
</ArgumentTypeCoercion>
</file>
<file src="src/Repository/DefaultRepository.php">
<ArgumentTypeCoercion occurrences="1"/>
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
}
],
"require": {
"php": "~8.0.0|~8.1.0",
"php": "~8.1.0",
"doctrine/dbal": "^3.2.0",
"psr/cache": "^2.0.0|^3.0.0",
"psr/log": "^2.0.0|^3.0.0",
"psr/simple-cache": "^2.0.0|^3.0.0",
"symfony/finder": "^4.4.34|^5.4.0|^6.0.1"
},
"require-dev": {
"ext-pdo_sqlite": "~8.0.0|~8.1.0",
"ext-pdo_sqlite": "~8.1.0",
"doctrine/migrations": "^3.3.2",
"infection/infection": "^0.26.0",
"patchlevel/coding-standard": "^1.1.1",
Expand Down
54 changes: 27 additions & 27 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ parameters:
path: src/EventBus/Message.php

-
message: "#^Property Patchlevel\\\\EventSourcing\\\\EventBus\\\\Message\\:\\:\\$headers \\(array\\{aggregateClass\\?\\: class\\-string\\<Patchlevel\\\\EventSourcing\\\\Aggregate\\\\AggregateRoot\\>, aggregateId\\?\\: string, playhead\\?\\: int, recordedOn\\?\\: DateTimeImmutable\\}\\) does not accept non\\-empty\\-array\\<T of string, mixed\\>\\.$#"
message: "#^Parameter \\#2 \\$headers of class Patchlevel\\\\EventSourcing\\\\EventBus\\\\Message constructor expects array\\{aggregateClass\\?\\: class\\-string\\<Patchlevel\\\\EventSourcing\\\\Aggregate\\\\AggregateRoot\\>, aggregateId\\?\\: string, playhead\\?\\: int, recordedOn\\?\\: DateTimeImmutable\\}, non\\-empty\\-array\\<T of string, mixed\\> given\\.$#"
count: 1
path: src/EventBus/Message.php

Expand Down
12 changes: 6 additions & 6 deletions src/EventBus/Message.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ final class Message
public const HEADER_PLAYHEAD = 'playhead';
public const HEADER_RECORDED_ON = 'recordedOn';

private object $event;
private readonly object $event;

/** @var array{aggregateClass?: class-string<AggregateRoot>, aggregateId?:string, playhead?:int, recordedOn?: DateTimeImmutable} */
private array $headers;
private readonly array $headers;

/**
* @param array{aggregateClass?: class-string<AggregateRoot>, aggregateId?:string, playhead?:int, recordedOn?: DateTimeImmutable} $headers
Expand Down Expand Up @@ -90,10 +90,10 @@ public function recordedOn(): DateTimeImmutable
*/
public function withHeader(string $name, mixed $value): self
{
$new = clone $this;
$new->headers[$name] = $value;

return $new;
return new self(
$this->event,
[$name => $value] + $this->headers
);
}

/**
Expand Down
17 changes: 7 additions & 10 deletions src/Metadata/AggregateRoot/AggregateRootMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,19 @@

namespace Patchlevel\EventSourcing\Metadata\AggregateRoot;

/**
* @readonly
*/
final class AggregateRootMetadata
{
public function __construct(
public string $name,
public readonly string $name,
/** @var array<class-string, string> */
public array $applyMethods,
public readonly array $applyMethods,
/** @var array<string, AggregateRootPropertyMetadata> */
public array $properties,
public readonly array $properties,
/** @var array<class-string, true> */
public array $suppressEvents,
public bool $suppressAll,
public ?string $snapshotStore,
public ?int $snapshotBatch,
public readonly array $suppressEvents,
public readonly bool $suppressAll,
public readonly ?string $snapshotStore,
public readonly ?int $snapshotBatch,
) {
}
}
9 changes: 3 additions & 6 deletions src/Metadata/AggregateRoot/AggregateRootPropertyMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@
use Patchlevel\EventSourcing\Serializer\Hydrator\Normalizer;
use ReflectionProperty;

/**
* @readonly
*/
final class AggregateRootPropertyMetadata
{
public function __construct(
public string $fieldName,
public ReflectionProperty $reflection,
public ?Normalizer $normalizer = null
public readonly string $fieldName,
public readonly ReflectionProperty $reflection,
public readonly ?Normalizer $normalizer = null
) {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Patchlevel\EventSourcing\Attribute\Snapshot;
use Patchlevel\EventSourcing\Attribute\SuppressMissingApply;
use ReflectionClass;
use ReflectionIntersectionType;
use ReflectionMethod;
use ReflectionNamedType;
use ReflectionUnionType;
Expand Down Expand Up @@ -190,11 +191,9 @@ private function getEventClassesByPropertyTypes(ReflectionMethod $method): array
throw new ArgumentTypeIsMissing($methodName);
}

/* needs psalm to undestand ReflectionIntersectionType
if ($propertyType instanceof ReflectionIntersectionType) {
throw new RuntimeException();
throw new ArgumentTypeIsMissing($methodName);
}
*/

if ($propertyType instanceof ReflectionNamedType) {
$eventClasses = [$propertyType->getName()];
Expand Down
7 changes: 2 additions & 5 deletions src/Metadata/Event/EventMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,12 @@

namespace Patchlevel\EventSourcing\Metadata\Event;

/**
* @readonly
*/
final class EventMetadata
{
public function __construct(
public string $name,
public readonly string $name,
/** @var array<string, EventPropertyMetadata> */
public array $properties = []
public readonly array $properties = []
) {
}
}
9 changes: 3 additions & 6 deletions src/Metadata/Event/EventPropertyMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@
use Patchlevel\EventSourcing\Serializer\Hydrator\Normalizer;
use ReflectionProperty;

/**
* @readonly
*/
final class EventPropertyMetadata
{
public function __construct(
public string $fieldName,
public ReflectionProperty $reflection,
public ?Normalizer $normalizer = null
public readonly string $fieldName,
public readonly ReflectionProperty $reflection,
public readonly ?Normalizer $normalizer = null
) {
}
}
7 changes: 2 additions & 5 deletions src/Metadata/Projection/ProjectionHandleMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,11 @@

namespace Patchlevel\EventSourcing\Metadata\Projection;

/**
* @readonly
*/
final class ProjectionHandleMetadata
{
public function __construct(
public string $methodName,
public bool $passMessage = false
public readonly string $methodName,
public readonly bool $passMessage = false
) {
}
}
9 changes: 3 additions & 6 deletions src/Metadata/Projection/ProjectionMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,13 @@

namespace Patchlevel\EventSourcing\Metadata\Projection;

/**
* @readonly
*/
final class ProjectionMetadata
{
public function __construct(
/** @var array<class-string, ProjectionHandleMetadata> */
public array $handleMethods,
public ?string $createMethod = null,
public ?string $dropMethod = null
public readonly array $handleMethods,
public readonly ?string $createMethod = null,
public readonly ?string $dropMethod = null
) {
}
}
Loading

0 comments on commit 36b1592

Please sign in to comment.