Add command bus, Drop PHP 8.1 #4943
Annotations
11 warnings
Mutation tests (locked, 8.3, ubuntu-latest)
ubuntu-latest pipelines will use ubuntu-24.04 soon. For more details, see https://github.com/actions/runner-images/issues/10636
|
Mutation tests (locked, 8.3, ubuntu-latest):
src/Aggregate/AggregateRootAttributeBehaviour.php#L27
Escaped Mutant for Mutator "ProtectedVisibility":
--- Original
+++ New
@@ @@
/** @var (callable(object $event): void)|null */
#[Ignore]
private $recorder = null;
- protected function apply(object $event) : void
+ private function apply(object $event) : void
{
$metadata = static::metadata();
if (!array_key_exists($event::class, $metadata->applyMethods)) {
|
Mutation tests (locked, 8.3, ubuntu-latest):
src/Aggregate/AggregateRootAttributeBehaviour.php#L66
Escaped Mutant for Mutator "AssignCoalesce":
--- Original
+++ New
@@ @@
private function passRecorderToChildAggregates() : void
{
$metadata = static::metadata();
- $this->recorder ??= $this->recordThat(...);
+ $this->recorder = $this->recordThat(...);
foreach ($metadata->childAggregates as $property) {
if (!isset($this->{$property})) {
continue;
|
Mutation tests (locked, 8.3, ubuntu-latest):
src/Aggregate/AggregateRootAttributeBehaviour.php#L81
Escaped Mutant for Mutator "InstanceOf_":
--- Original
+++ New
@@ @@
}
public function aggregateRootId() : AggregateRootId
{
- if ($this->cachedAggregateRootId instanceof AggregateRootId) {
+ if (false) {
return $this->cachedAggregateRootId;
}
$metadata = static::metadata();
|
Mutation tests (locked, 8.3, ubuntu-latest):
src/CommandBus/AggregateHandlerProvider.php#L70
Escaped Mutant for Mutator "TrueValue":
--- Original
+++ New
@@ @@
$this->handlers[$handler->commandClass][] = new HandlerDescriptor(new UpdateAggregateHandler($this->repositoryManager, $aggregateClass, $handler->method, new DefaultParameterResolver($this->container)));
}
}
- $this->initialized = true;
+ $this->initialized = false;
}
}
|
Mutation tests (locked, 8.3, ubuntu-latest):
src/CommandBus/DefaultCommandBus.php#L57
Escaped Mutant for Mutator "UnwrapFinally":
--- Original
+++ New
@@ @@
$this->logger?->debug('CommandBus: Is already processing, dont start new processing.');
return;
}
- try {
- $this->processing = true;
- $this->logger?->debug('CommandBus: Start processing queue.');
- while ($command = array_shift($this->queue)) {
- $handlers = $this->handlerProvider->handlerForCommand($command::class);
- if (!is_array($handlers)) {
- $handlers = iterator_to_array($handlers);
- }
- $count = count($handlers);
- if ($count === 0) {
- throw new HandlerNotFound($command::class);
- }
- if ($count > 1) {
- throw new MultipleHandlersFound($command::class);
- }
- $handlers[0]->callable()($command);
+ $this->processing = true;
+ $this->logger?->debug('CommandBus: Start processing queue.');
+ while ($command = array_shift($this->queue)) {
+ $handlers = $this->handlerProvider->handlerForCommand($command::class);
+ if (!is_array($handlers)) {
+ $handlers = iterator_to_array($handlers);
}
- } finally {
- $this->processing = false;
- $this->logger?->debug('CommandBus: Finished processing queue.');
+ $count = count($handlers);
+ if ($count === 0) {
+ throw new HandlerNotFound($command::class);
+ }
+ if ($count > 1) {
+ throw new MultipleHandlersFound($command::class);
+ }
+ $handlers[0]->callable()($command);
}
+ $this->processing = false;
+ $this->logger?->debug('CommandBus: Finished processing queue.');
}
public static function createForAggregateHandlers(AggregateRootRegistry $aggregateRootRegistry, RepositoryManager $repositoryManager, ContainerInterface|null $container = null, LoggerInterface|null $logger = null) : self
{
|
Mutation tests (locked, 8.3, ubuntu-latest):
src/CommandBus/DefaultCommandBus.php#L58
Escaped Mutant for Mutator "TrueValue":
--- Original
+++ New
@@ @@
return;
}
try {
- $this->processing = true;
+ $this->processing = false;
$this->logger?->debug('CommandBus: Start processing queue.');
while ($command = array_shift($this->queue)) {
$handlers = $this->handlerProvider->handlerForCommand($command::class);
|
Mutation tests (locked, 8.3, ubuntu-latest):
src/CommandBus/DefaultCommandBus.php#L82
Escaped Mutant for Mutator "FalseValue":
--- Original
+++ New
@@ @@
$handlers[0]->callable()($command);
}
} finally {
- $this->processing = false;
+ $this->processing = true;
$this->logger?->debug('CommandBus: Finished processing queue.');
}
}
|
Mutation tests (locked, 8.3, ubuntu-latest):
src/CommandBus/Handler/UpdateAggregateHandler.php#L35
Escaped Mutant for Mutator "MethodCallRemoval":
--- Original
+++ New
@@ @@
$aggregate = $repository->load($aggregateRootId);
$reflection = new ReflectionClass($this->aggregateClass);
$reflectionMethod = $reflection->getMethod($this->methodName);
- $reflectionMethod->invokeArgs($aggregate, [...$this->parameterResolver->resolve($reflectionMethod, $command)]);
+
$repository->save($aggregate);
}
private function aggregateRootId(object $command) : AggregateRootId
|
Mutation tests (locked, 8.3, ubuntu-latest):
src/CommandBus/HandlerFinder.php#L40
Escaped Mutant for Mutator "Continue_":
--- Original
+++ New
@@ @@
$handle = $handleAttributes[0]->newInstance();
if ($handle->commandClass !== null) {
(yield new HandlerReference($handle->commandClass, $reflectionMethod->getName(), $reflectionMethod->isStatic()));
- continue;
+ break;
}
$parameters = $reflectionMethod->getParameters();
if ($parameters === []) {
|
Mutation tests (locked, 8.3, ubuntu-latest):
src/Console/Command/DatabaseCreateCommand.php#L49
Escaped Mutant for Mutator "LogicalAnd":
--- Original
+++ New
@@ @@
$tempConnection = $this->helper->copyConnectionWithoutDatabase($this->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;
|