Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update codestyle #430

Merged
merged 2 commits into from
Dec 12, 2023
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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
30 changes: 11 additions & 19 deletions baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,15 @@
<code>MetadataAwareProjectionHandler::class</code>
<code><![CDATA[new MetadataAwareProjectionHandler(
$projections,
$projectionHandler->metadataFactory()
$projectionHandler->metadataFactory(),
)]]></code>
</DeprecatedClass>
<DeprecatedInterface>
<code>ProjectionHandler</code>
<code>ProjectionHandler</code>
<code>ProjectionHandler</code>
<code>ProjectionHandler</code>
<code><![CDATA[non-empty-array<class-string<Projection>>]]></code>
<code><![CDATA[non-empty-array<class-string<Projection>>|null]]></code>
<code>private</code>
</DeprecatedInterface>
<InvalidOperand>
<code><![CDATA[$projectionHandler->projections()]]></code>
Expand All @@ -42,20 +41,17 @@
</file>
<file src="src/Console/Command/SchemaCreateCommand.php">
<DeprecatedInterface>
<code>SchemaManager|SchemaDirector</code>
<code>SchemaManager|SchemaDirector $schemaDirector</code>
<code>private</code>
</DeprecatedInterface>
</file>
<file src="src/Console/Command/SchemaDropCommand.php">
<DeprecatedInterface>
<code>SchemaManager|SchemaDirector</code>
<code>SchemaManager|SchemaDirector $schemaDirector</code>
<code>private</code>
</DeprecatedInterface>
</file>
<file src="src/Console/Command/SchemaUpdateCommand.php">
<DeprecatedInterface>
<code>SchemaManager|SchemaDirector</code>
<code>SchemaManager|SchemaDirector $schemaDirector</code>
<code>private</code>
</DeprecatedInterface>
</file>
<file src="src/Console/DoctrineHelper.php">
Expand Down Expand Up @@ -124,22 +120,20 @@
</file>
<file src="src/Pipeline/Source/StoreSource.php">
<DeprecatedInterface>
<code>PipelineStore</code>
<code>PipelineStore</code>
<code>private</code>
</DeprecatedInterface>
</file>
<file src="src/Pipeline/Target/ProjectionHandlerTarget.php">
<DeprecatedInterface>
<code>ProjectionHandler</code>
<code>ProjectionHandler</code>
<code>private</code>
</DeprecatedInterface>
</file>
<file src="src/Pipeline/Target/ProjectionTarget.php">
<DeprecatedClass>
<code>MetadataAwareProjectionHandler</code>
<code>new MetadataAwareProjectionHandler(
[$projection],
$projectionMetadataFactory
$projectionMetadataFactory,
)</code>
</DeprecatedClass>
<DeprecatedInterface>
Expand All @@ -149,7 +143,6 @@
<file src="src/Projection/MetadataAwareProjectionHandler.php">
<DeprecatedInterface>
<code>MetadataAwareProjectionHandler</code>
<code>iterable</code>
<code><![CDATA[iterable<Projection>]]></code>
<code><![CDATA[iterable<Projection>]]></code>
</DeprecatedInterface>
Expand All @@ -164,8 +157,7 @@
</file>
<file src="src/Projection/ProjectionListener.php">
<DeprecatedInterface>
<code>ProjectionHandler</code>
<code>ProjectionHandler</code>
<code>private</code>
</DeprecatedInterface>
</file>
<file src="src/Projection/Projector/InMemoryProjectorRepository.php">
Expand Down Expand Up @@ -270,7 +262,7 @@
<file src="tests/Benchmark/WriteEventsBench.php">
<DeprecatedClass>
<code>new MetadataAwareProjectionHandler(
[$profileProjection]
[$profileProjection],
)</code>
<code>new ProjectionListener($projectionRepository)</code>
</DeprecatedClass>
Expand Down Expand Up @@ -306,7 +298,7 @@
<file src="tests/Integration/Outbox/OutboxTest.php">
<DeprecatedClass>
<code>new MetadataAwareProjectionHandler(
[$profileProjection]
[$profileProjection],
)</code>
<code>new ProjectionListener($projectionRepository)</code>
</DeprecatedClass>
Expand Down
6 changes: 2 additions & 4 deletions src/Aggregate/AggregateRoot.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

abstract class AggregateRoot
{
private static ?AggregateRootMetadataFactory $metadataFactory = null;
private static AggregateRootMetadataFactory|null $metadataFactory = null;

/** @var list<object> */
private array $uncommittedEvents = [];
Expand All @@ -25,7 +25,7 @@

abstract public function aggregateRootId(): string;

protected function apply(object $event): void

Check warning on line 28 in src/Aggregate/AggregateRoot.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "ProtectedVisibility": --- Original +++ New @@ @@ { } public abstract function aggregateRootId() : string; - protected function apply(object $event) : void + private function apply(object $event) : void { $metadata = self::metadata(); if (!array_key_exists($event::class, $metadata->applyMethods)) {
{
$metadata = self::metadata();

Expand Down Expand Up @@ -55,7 +55,7 @@
*
* @param list<object> $events
*/
final public function catchUp(array $events): void

Check warning on line 58 in src/Aggregate/AggregateRoot.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "PublicVisibility": --- Original +++ New @@ @@ * * @param list<object> $events */ - public final function catchUp(array $events) : void + protected final function catchUp(array $events) : void { foreach ($events as $event) { $this->playhead++;
{
foreach ($events as $event) {
$this->playhead++;
Expand All @@ -63,9 +63,7 @@
}
}

/**
* @return list<object>
*/
/** @return list<object> */
final public function releaseEvents(): array
{
$events = $this->uncommittedEvents;
Expand Down
4 changes: 2 additions & 2 deletions src/Aggregate/ApplyMethodNotFound.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ public function __construct(string $aggregate, string $event)
sprintf(
'Apply method in "%s" could not be found for the event "%s"',
$aggregate,
$event
)
$event,
),
);
}
}
5 changes: 1 addition & 4 deletions src/Attribute/Aggregate.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
#[Attribute(Attribute::TARGET_CLASS)]
final class Aggregate
{
private string $name;

public function __construct(string $name)
public function __construct(private string $name)
{
$this->name = $name;
}

public function name(): string
Expand Down
16 changes: 4 additions & 12 deletions src/Attribute/Apply.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,13 @@
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
final class Apply
{
/** @var class-string|null */
private ?string $eventClass;

/**
* @param class-string|null $eventClass
*/
public function __construct(?string $eventClass = null)
/** @param class-string|null $eventClass */
public function __construct(private string|null $eventClass = null)
{
$this->eventClass = $eventClass;
}

/**
* @return class-string|null
*/
public function eventClass(): ?string
/** @return class-string|null */
public function eventClass(): string|null
{
return $this->eventClass;
}
Expand Down
5 changes: 1 addition & 4 deletions src/Attribute/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
#[Attribute(Attribute::TARGET_CLASS)]
final class Event
{
private string $name;

public function __construct(string $name)
public function __construct(private string $name)
{
$this->name = $name;
}

public function name(): string
Expand Down
14 changes: 3 additions & 11 deletions src/Attribute/Handle.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,12 @@
#[Attribute(Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
final class Handle
{
/** @var class-string */
private string $eventClass;

/**
* @param class-string $eventClass
*/
public function __construct(string $eventClass)
/** @param class-string $eventClass */
public function __construct(private string $eventClass)
{
$this->eventClass = $eventClass;
}

/**
* @return class-string
*/
/** @return class-string */
public function eventClass(): string
{
return $this->eventClass;
Expand Down
5 changes: 1 addition & 4 deletions src/Attribute/NormalizedName.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,8 @@
#[Attribute(Attribute::TARGET_PROPERTY)]
final class NormalizedName
{
private string $name;

public function __construct(string $name)
public function __construct(private string $name)
{
$this->name = $name;
}

public function name(): string
Expand Down
13 changes: 3 additions & 10 deletions src/Attribute/Snapshot.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,21 @@
#[Attribute(Attribute::TARGET_CLASS)]
final class Snapshot
{
private string $name;
private ?int $batch;
private ?string $version;

public function __construct(string $name, ?int $batch = null, ?string $version = null)
public function __construct(private string $name, private int|null $batch = null, private string|null $version = null)
{
$this->name = $name;
$this->batch = $batch;
$this->version = $version;
}

public function name(): string
{
return $this->name;
}

public function batch(): ?int
public function batch(): int|null
{
return $this->batch;
}

public function version(): ?string
public function version(): string|null
{
return $this->version;
}
Expand Down
8 changes: 2 additions & 6 deletions src/Attribute/SuppressMissingApply.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,7 @@ final class SuppressMissingApply
private array $suppressEvents = [];
private bool $suppressAll = false;

/**
* @param list<class-string>|self::ALL $suppress
*/
/** @param list<class-string>|self::ALL $suppress */
public function __construct(string|array $suppress)
{
if ($suppress === self::ALL) {
Expand All @@ -29,9 +27,7 @@ public function __construct(string|array $suppress)
$this->suppressEvents = $suppress;
}

/**
* @return list<class-string>
*/
/** @return list<class-string> */
public function suppressEvents(): array
{
return $this->suppressEvents;
Expand Down
4 changes: 1 addition & 3 deletions src/Clock/FrozenClock.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ public function update(DateTimeImmutable $frozenDateTime): void
$this->frozenDateTime = $frozenDateTime;
}

/**
* @param positive-int $seconds
*/
/** @param positive-int $seconds */
public function sleep(int $seconds): void
{
$this->frozenDateTime = $this->frozenDateTime->modify(sprintf('+%s seconds', $seconds));
Expand Down
10 changes: 2 additions & 8 deletions src/Console/Command/DatabaseCreateCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,13 @@

#[AsCommand(
'event-sourcing:database:create',
'create eventstore database'
'create eventstore database',
)]
final class DatabaseCreateCommand extends Command
{
private Store $store;
private DoctrineHelper $helper;

public function __construct(Store $store, DoctrineHelper $helper)
public function __construct(private Store $store, private DoctrineHelper $helper)
{
parent::__construct();

$this->store = $store;
$this->helper = $helper;
}

protected function configure(): void
Expand Down Expand Up @@ -60,9 +54,9 @@
$ifNotExists = InputHelper::bool($input->getOption('if-not-exists'));
$hasDatabase = $this->helper->hasDatabase($tempConnection, $databaseName);

if ($ifNotExists && $hasDatabase) {

Check warning on line 57 in src/Console/Command/DatabaseCreateCommand.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ $tempConnection = $this->helper->copyConnectionWithoutDatabase($connection); $ifNotExists = InputHelper::bool($input->getOption('if-not-exists')); $hasDatabase = $this->helper->hasDatabase($tempConnection, $databaseName); - if ($ifNotExists && $hasDatabase) { + if ($ifNotExists || $hasDatabase) { $console->warning(sprintf('Database "%s" already exists. Skipped.', $databaseName)); $tempConnection->close(); return 0;
$console->warning(sprintf('Database "%s" already exists. Skipped.', $databaseName));
$tempConnection->close();

Check warning on line 59 in src/Console/Command/DatabaseCreateCommand.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $hasDatabase = $this->helper->hasDatabase($tempConnection, $databaseName); if ($ifNotExists && $hasDatabase) { $console->warning(sprintf('Database "%s" already exists. Skipped.', $databaseName)); - $tempConnection->close(); + return 0; } try {

return 0;
}
Expand All @@ -72,14 +66,14 @@
$console->success(sprintf('Created database "%s"', $databaseName));
} catch (Throwable $e) {
$console->error(sprintf('Could not create database "%s"', $databaseName));
$console->error($e->getMessage());

Check warning on line 69 in src/Console/Command/DatabaseCreateCommand.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $console->success(sprintf('Created database "%s"', $databaseName)); } catch (Throwable $e) { $console->error(sprintf('Could not create database "%s"', $databaseName)); - $console->error($e->getMessage()); + $tempConnection->close(); return 2; }

$tempConnection->close();

Check warning on line 71 in src/Console/Command/DatabaseCreateCommand.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ } catch (Throwable $e) { $console->error(sprintf('Could not create database "%s"', $databaseName)); $console->error($e->getMessage()); - $tempConnection->close(); + return 2; } $tempConnection->close();

return 2;
}

$tempConnection->close();

Check warning on line 76 in src/Console/Command/DatabaseCreateCommand.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $tempConnection->close(); return 2; } - $tempConnection->close(); + return 0; } }

return 0;
}
Expand Down
10 changes: 2 additions & 8 deletions src/Console/Command/DatabaseDropCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,13 @@

#[AsCommand(
'event-sourcing:database:drop',
'drop eventstore database'
'drop eventstore database',
)]
final class DatabaseDropCommand extends Command
{
private Store $store;
private DoctrineHelper $helper;

public function __construct(Store $store, DoctrineHelper $helper)
public function __construct(private Store $store, private DoctrineHelper $helper)
{
parent::__construct();

$this->store = $store;
$this->helper = $helper;
}

protected function configure(): void
Expand Down Expand Up @@ -61,8 +55,8 @@

if (!$force) {
$console->caution('This operation should not be executed in a production environment.');
$console->warning(sprintf('Would drop the database "%s". Please run the operation with --force to execute.', $databaseName));

Check warning on line 58 in src/Console/Command/DatabaseDropCommand.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ $force = InputHelper::bool($input->getOption('force')); if (!$force) { $console->caution('This operation should not be executed in a production environment.'); - $console->warning(sprintf('Would drop the database "%s". Please run the operation with --force to execute.', $databaseName)); + $console->caution('All data will be lost!'); return 2; }
$console->caution('All data will be lost!');

Check warning on line 59 in src/Console/Command/DatabaseDropCommand.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "MethodCallRemoval": --- Original +++ New @@ @@ if (!$force) { $console->caution('This operation should not be executed in a production environment.'); $console->warning(sprintf('Would drop the database "%s". Please run the operation with --force to execute.', $databaseName)); - $console->caution('All data will be lost!'); + return 2; } $ifExists = InputHelper::bool($input->getOption('if-exists'));

return 2;
}
Expand All @@ -70,7 +64,7 @@
$ifExists = InputHelper::bool($input->getOption('if-exists'));
$hasDatabase = $this->helper->hasDatabase($tempConnection, $databaseName);

if ($ifExists && !$hasDatabase) {

Check warning on line 67 in src/Console/Command/DatabaseDropCommand.php

View workflow job for this annotation

GitHub Actions / Mutation tests (locked, 8.3, ubuntu-latest)

Escaped Mutant for Mutator "LogicalAnd": --- Original +++ New @@ @@ } $ifExists = InputHelper::bool($input->getOption('if-exists')); $hasDatabase = $this->helper->hasDatabase($tempConnection, $databaseName); - if ($ifExists && !$hasDatabase) { + if ($ifExists || !$hasDatabase) { $console->warning(sprintf('Database "%s" doesn\'t exist. Skipped.', $databaseName)); return 0; }
$console->warning(sprintf('Database "%s" doesn\'t exist. Skipped.', $databaseName));

return 0;
Expand Down
8 changes: 4 additions & 4 deletions src/Console/Command/DebugCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@
#[AsCommand(
'event-sourcing:debug',
'show event sourcing debug information',
['debug:event-sourcing']
['debug:event-sourcing'],
)]
final class DebugCommand extends Command
{
public function __construct(
private readonly AggregateRootRegistry $aggregateRootRegistry,
private readonly EventRegistry $eventRegistry
private readonly EventRegistry $eventRegistry,
) {
parent::__construct();
}
Expand All @@ -48,7 +48,7 @@ private function showAggregates(OutputStyle $console): void

$console->table(
['name', 'class'],
array_map(null, array_keys($aggregates), array_values($aggregates))
array_map(null, array_keys($aggregates), array_values($aggregates)),
);
}

Expand All @@ -60,7 +60,7 @@ private function showEvents(OutputStyle $console): void

$console->table(
['name', 'class'],
array_map(null, array_keys($events), array_values($events))
array_map(null, array_keys($events), array_values($events)),
);
}
}
Loading
Loading