Run mutation testing with infection

Created on 15 August 2023, over 1 year ago

Problem/Motivation

Steps to reproduce

Proposed resolution

Remaining tasks

Initial infection report:
Escaped mutants:
================

1) modules/core_event_dispatcher/src/Event/Entity/EntityBuildDefaultsAlterEvent.php:42 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
      */
     public function __construct(array &$build, EntityInterface $entity, private string $viewMode)
     {
-        parent::__construct($entity);
+        
         $this->build =& $build;
     }
     /**

2) modules/core_event_dispatcher/src/Event/Entity/EntityPresaveEvent.php:27 [M] Coalesce

--- Original
+++ New
@@ @@
      */
     public function getOriginalEntity() : ?EntityInterface
     {
-        return $this->entity->original ?? NULL;
+        return NULL ?? $this->entity->original;
     }
     /**
      * {@inheritdoc}

3) modules/core_event_dispatcher/src/Event/Entity/EntityUpdateEvent.php:27 [M] Coalesce

--- Original
+++ New
@@ @@
      */
     public function getOriginalEntity() : ?EntityInterface
     {
-        return $this->entity->original ?? NULL;
+        return NULL ?? $this->entity->original;
     }
     /**
      * {@inheritdoc}

4) modules/core_event_dispatcher/src/Event/Entity/EntityViewAlterEvent.php:40 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
      */
     public function __construct(array &$build, EntityInterface $entity, private EntityViewDisplayInterface $display)
     {
-        parent::__construct($entity);
+        
         $this->build =& $build;
     }
     /**

5) modules/core_event_dispatcher/src/Event/Entity/EntityViewEvent.php:47 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
      */
     public function __construct(array &$build, EntityInterface $entity, private EntityViewDisplayInterface $display, private string $viewMode)
     {
-        parent::__construct($entity);
+        
         $this->build =& $build;
     }
     /**

6) modules/core_event_dispatcher/src/Event/File/FileDownloadEvent.php:54 [M] TrueValue

--- Original
+++ New
@@ @@
      */
     public function setForbidden() : void
     {
-        $this->forbidden = TRUE;
+        $this->forbidden = false;
     }
     /**
      * Gets the response headers.

7) modules/core_event_dispatcher/src/Event/Token/TokensReplacementEvent.php:104 [M] Coalesce

--- Original
+++ New
@@ @@
      */
     public function getData(string $key, $default = NULL)
     {
-        return $this->data[$key] ?? $default;
+        return $default ?? $this->data[$key];
     }
     /**
      * Getter.

8) modules/core_event_dispatcher/src/Event/Token/TokensReplacementEvent.php:184 [M] InstanceOf_

--- Original
+++ New
@@ @@
         if (!$this->forToken($type, $token)) {
             throw new \UnexpectedValueException('Requested replacement is not requested');
         }
-        if (!is_string($replacement) && !$replacement instanceof MarkupInterface) {
+        if (!is_string($replacement) && !false) {
             throw new \UnexpectedValueException('Replacement value should be a string or instanceof MarkupInterface');
         }
         $this->replacementValues[sprintf('[%s:%s]', $type, $token)] = $replacement;

9) modules/core_event_dispatcher/src/ValueObject/Token.php:86 [M] CloneRemoval

--- Original
+++ New
@@ @@
      */
     public function setDescription(MarkupInterface|string $description) : self
     {
-        $clone = clone $this;
+        $clone = $this;
         $clone->description = $description;
         return $clone;
     }

10) modules/core_event_dispatcher/src/ValueObject/Token.php:101 [M] CloneRemoval

--- Original
+++ New
@@ @@
      */
     public function setDynamic(bool $dynamic) : self
     {
-        $clone = clone $this;
+        $clone = $this;
         $clone->dynamic = $dynamic;
         return $clone;
     }

11) modules/core_event_dispatcher/src/ValueObject/TokenType.php:76 [M] CloneRemoval

--- Original
+++ New
@@ @@
      */
     public function setDescription(MarkupInterface|string $description) : self
     {
-        $clone = clone $this;
+        $clone = $this;
         $clone->description = $description;
         return $clone;
     }

12) modules/core_event_dispatcher/src/ValueObject/TokenType.php:91 [M] CloneRemoval

--- Original
+++ New
@@ @@
      */
     public function setNeedsData(string $needsData) : self
     {
-        $clone = clone $this;
+        $clone = $this;
         $clone->needsData = $needsData;
         return $clone;
     }

13) modules/field_event_dispatcher/src/EventSubscriber/Form/FormEntityDisplayEditAlterEventSubscriber.php:18 [M] ArrayItemRemoval

--- Original
+++ New
@@ @@
      */
     public static function getSubscribedEvents() : array
     {
-        return ['hook_event_dispatcher.form_entity_view_display_edit_form.alter' => 'formAlter', 'hook_event_dispatcher.form_entity_form_display_edit_form.alter' => 'formAlter'];
+        return ['hook_event_dispatcher.form_entity_form_display_edit_form.alter' => 'formAlter'];
     }
     /**
      * Alter the entity edit form third-party elements structure.

14) modules/preprocess_event_dispatcher/src/Service/PreprocessEventFactoryMapper.php:40 [M] Coalesce

--- Original
+++ New
@@ @@
      */
     public function getFactory(string $hook) : ?PreprocessEventFactoryInterface
     {
-        return $this->hookToFactoryMap[$hook] ?? NULL;
+        return NULL ?? $this->hookToFactoryMap[$hook];
     }
 }

15) modules/preprocess_event_dispatcher/src/Service/PreprocessEventService.php:36 [M] InstanceOf_

--- Original
+++ New
@@ @@
         }
         $event = $factory->createEvent($variables);
         $this->dispatcher->dispatch($event, $event::name());
-        if ($event instanceof PreprocessEntityEventInterface) {
+        if (false) {
             $this->dispatchEntitySpecificEvents($event);
         }
     }

16) modules/views_event_dispatcher/src/Event/Views/ViewsPostRenderEvent.php:34 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
      */
     public function __construct(ViewExecutable $view, &$output, private CachePluginBase $cache)
     {
-        parent::__construct($view);
+        
         $this->output =& $output;
     }
     /**

17) modules/views_event_dispatcher/src/Event/Views/ViewsQueryAlterEvent.php:25 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
      */
     public function __construct(ViewExecutable $view, private QueryPluginBase $query)
     {
-        parent::__construct($view);
+        
     }
     /**
      * Get the query.

Timed Out mutants:
==================

Skipped mutants:
================

1) src/Event/AccessEventTrait.php:53 [M] Coalesce

--- Original
+++ New
@@ @@
      */
     public function getAccessResult() : AccessResultInterface
     {
-        return $this->accessResult ?? AccessResult::neutral();
+        return AccessResult::neutral() ?? $this->accessResult;
     }
     /**
      * {@inheritdoc}

2) src/HookEventDispatcherModuleHandler.php:51 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
     public function invokeAll($hook, array $args = [])
     {
         $return = [];
-        $this->invokeAllWith($hook, static function (callable $hookInvoker, string $module) use($args, &$return) {
-            $result = $hookInvoker(...$args);
-            if (isset($result) && is_array($result)) {
-                $return = NestedArray::mergeDeep($return, $result);
-            } elseif (isset($result)) {
-                $return[] = $result;
-            }
-        });
+        
         return $return;
     }
     /**

3) src/HookEventDispatcherModuleHandler.php:53 [M] LogicalAnd

--- Original
+++ New
@@ @@
         $return = [];
         $this->invokeAllWith($hook, static function (callable $hookInvoker, string $module) use($args, &$return) {
             $result = $hookInvoker(...$args);
-            if (isset($result) && is_array($result)) {
+            if (isset($result) || is_array($result)) {
                 $return = NestedArray::mergeDeep($return, $result);
             } elseif (isset($result)) {
                 $return[] = $result;

4) src/HookEventDispatcherModuleHandler.php:67 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
      */
     public function invokeAllWith(string $hook, callable $callback) : void
     {
-        $this->inner->invokeAllWith($hook, $callback);
+        
         if (!isset($this->hookFactories[$hook])) {
             $this->hookFactories[$hook] = iterator_to_array($this->pluginManager->getHookEventFactories($hook));
         }

5) src/HookEventDispatcherModuleHandler.php:69 [M] LogicalNot

--- Original
+++ New
@@ @@
     public function invokeAllWith(string $hook, callable $callback) : void
     {
         $this->inner->invokeAllWith($hook, $callback);
-        if (!isset($this->hookFactories[$hook])) {
+        if (isset($this->hookFactories[$hook])) {
             $this->hookFactories[$hook] = iterator_to_array($this->pluginManager->getHookEventFactories($hook));
         }
         foreach ($this->hookFactories[$hook] as $eventFactory) {

6) src/HookEventDispatcherModuleHandler.php:73 [M] Foreach_

--- Original
+++ New
@@ @@
         if (!isset($this->hookFactories[$hook])) {
             $this->hookFactories[$hook] = iterator_to_array($this->pluginManager->getHookEventFactories($hook));
         }
-        foreach ($this->hookFactories[$hook] as $eventFactory) {
+        foreach (array() as $eventFactory) {
             $callback(function (&...$args) use($eventFactory) {
                 $event = $eventFactory(...$args);
                 $this->dispatcherManager->register($event);

7) src/HookEventDispatcherModuleHandler.php:74 [M] FunctionCallRemoval

--- Original
+++ New
@@ @@
             $this->hookFactories[$hook] = iterator_to_array($this->pluginManager->getHookEventFactories($hook));
         }
         foreach ($this->hookFactories[$hook] as $eventFactory) {
-            $callback(function (&...$args) use($eventFactory) {
-                $event = $eventFactory(...$args);
-                $this->dispatcherManager->register($event);
-                return $event instanceof HookReturnInterface ? $event->getReturnValue() : NULL;
-            }, 'hook_event_dispatcher');
+            
         }
     }
     /**

8) src/HookEventDispatcherModuleHandler.php:76 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
         foreach ($this->hookFactories[$hook] as $eventFactory) {
             $callback(function (&...$args) use($eventFactory) {
                 $event = $eventFactory(...$args);
-                $this->dispatcherManager->register($event);
+                
                 return $event instanceof HookReturnInterface ? $event->getReturnValue() : NULL;
             }, 'hook_event_dispatcher');
         }

9) src/HookEventDispatcherModuleHandler.php:78 [M] InstanceOf_

--- Original
+++ New
@@ @@
             $callback(function (&...$args) use($eventFactory) {
                 $event = $eventFactory(...$args);
                 $this->dispatcherManager->register($event);
-                return $event instanceof HookReturnInterface ? $event->getReturnValue() : NULL;
+                return true ? $event->getReturnValue() : NULL;
             }, 'hook_event_dispatcher');
         }
     }

10) src/HookEventDispatcherModuleHandler.php:78 [M] InstanceOf_

--- Original
+++ New
@@ @@
             $callback(function (&...$args) use($eventFactory) {
                 $event = $eventFactory(...$args);
                 $this->dispatcherManager->register($event);
-                return $event instanceof HookReturnInterface ? $event->getReturnValue() : NULL;
+                return false ? $event->getReturnValue() : NULL;
             }, 'hook_event_dispatcher');
         }
     }

11) src/HookEventDispatcherModuleHandler.php:78 [M] Ternary

--- Original
+++ New
@@ @@
             $callback(function (&...$args) use($eventFactory) {
                 $event = $eventFactory(...$args);
                 $this->dispatcherManager->register($event);
-                return $event instanceof HookReturnInterface ? $event->getReturnValue() : NULL;
+                return $event instanceof HookReturnInterface ? NULL : $event->getReturnValue();
             }, 'hook_event_dispatcher');
         }
     }

12) src/HookEventDispatcherModuleHandler.php:87 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
      */
     public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) : void
     {
-        $this->inner->alter($type, $data, $context1, $context2);
+        
         $types = is_array($type) ? $type : [$type];
         foreach ($types as $alter) {
             if (!isset($this->alterFactories[$alter])) {

13) src/HookEventDispatcherModuleHandler.php:89 [M] ArrayItemRemoval

--- Original
+++ New
@@ @@
     public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) : void
     {
         $this->inner->alter($type, $data, $context1, $context2);
-        $types = is_array($type) ? $type : [$type];
+        $types = is_array($type) ? $type : [];
         foreach ($types as $alter) {
             if (!isset($this->alterFactories[$alter])) {
                 $this->alterFactories[$alter] = [];

14) src/HookEventDispatcherModuleHandler.php:89 [M] Ternary

--- Original
+++ New
@@ @@
     public function alter($type, &$data, &$context1 = NULL, &$context2 = NULL) : void
     {
         $this->inner->alter($type, $data, $context1, $context2);
-        $types = is_array($type) ? $type : [$type];
+        $types = is_array($type) ? [$type] : $type;
         foreach ($types as $alter) {
             if (!isset($this->alterFactories[$alter])) {
                 $this->alterFactories[$alter] = [];

15) src/HookEventDispatcherModuleHandler.php:90 [M] Foreach_

--- Original
+++ New
@@ @@
     {
         $this->inner->alter($type, $data, $context1, $context2);
         $types = is_array($type) ? $type : [$type];
-        foreach ($types as $alter) {
+        foreach (array() as $alter) {
             if (!isset($this->alterFactories[$alter])) {
                 $this->alterFactories[$alter] = [];
                 foreach ($this->pluginManager->getAlterEventFactories($alter) as $eventFactory) {

16) src/HookEventDispatcherModuleHandler.php:91 [M] LogicalNot

--- Original
+++ New
@@ @@
         $this->inner->alter($type, $data, $context1, $context2);
         $types = is_array($type) ? $type : [$type];
         foreach ($types as $alter) {
-            if (!isset($this->alterFactories[$alter])) {
+            if (isset($this->alterFactories[$alter])) {
                 $this->alterFactories[$alter] = [];
                 foreach ($this->pluginManager->getAlterEventFactories($alter) as $eventFactory) {
                     $this->alterFactories[$alter][] = $eventFactory;

17) src/HookEventDispatcherModuleHandler.php:93 [M] Foreach_

--- Original
+++ New
@@ @@
         foreach ($types as $alter) {
             if (!isset($this->alterFactories[$alter])) {
                 $this->alterFactories[$alter] = [];
-                foreach ($this->pluginManager->getAlterEventFactories($alter) as $eventFactory) {
+                foreach (array() as $eventFactory) {
                     $this->alterFactories[$alter][] = $eventFactory;
                 }
             }

18) src/HookEventDispatcherModuleHandler.php:98 [M] Foreach_

--- Original
+++ New
@@ @@
                     $this->alterFactories[$alter][] = $eventFactory;
                 }
             }
-            foreach ($this->alterFactories[$alter] as $eventFactory) {
+            foreach (array() as $eventFactory) {
                 $event = $eventFactory($data, $context1, $context2);
                 $this->dispatcherManager->register($event);
             }

19) src/HookEventDispatcherModuleHandler.php:100 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
             }
             foreach ($this->alterFactories[$alter] as $eventFactory) {
                 $event = $eventFactory($data, $context1, $context2);
-                $this->dispatcherManager->register($event);
+                
             }
         }
     }
 }

20) src/HookEventDispatcherModuleHandlerProxyTrait.php:23 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
      */
     public function loadAll()
     {
-        $this->inner->loadAll();
+        
     }
     /**
      * {@inheritdoc}

21) src/HookEventPluginManager.php:32 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
      */
     public function __construct(\Traversable $namespaces, CacheBackendInterface $cacheBackend, ModuleHandlerInterface $moduleHandler)
     {
-        parent::__construct('Event', $namespaces, $moduleHandler, EventInterface::class, HookEvent::class);
+        
         $this->alterInfo('hook_event_info');
         $this->setCacheBackend($cacheBackend, 'hook_event_plugins');
     }

22) src/HookEventPluginManager.php:39 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
     public function __construct(\Traversable $namespaces, CacheBackendInterface $cacheBackend, ModuleHandlerInterface $moduleHandler)
     {
         parent::__construct('Event', $namespaces, $moduleHandler, EventInterface::class, HookEvent::class);
-        $this->alterInfo('hook_event_info');
+        
         $this->setCacheBackend($cacheBackend, 'hook_event_plugins');
     }
     /**

23) src/HookEventPluginManager.php:40 [M] MethodCallRemoval

--- Original
+++ New
@@ @@
     {
         parent::__construct('Event', $namespaces, $moduleHandler, EventInterface::class, HookEvent::class);
         $this->alterInfo('hook_event_info');
-        $this->setCacheBackend($cacheBackend, 'hook_event_plugins');
+        
     }
     /**
      * {@inheritdoc}

24) src/HookEventPluginManager.php:47 [M] LogicalNot

--- Original
+++ New
@@ @@
      */
     protected function getFactory()
     {
-        if (!$this->factory) {
+        if ($this->factory) {
             $this->factory = new EventFactory($this, $this->pluginInterface);
         }
         return $this->factory;

25) src/HookEventPluginManager.php:58 [M] Foreach_

--- Original
+++ New
@@ @@
      */
     public function getHookEventFactories(string $hook) : \Generator
     {
-        foreach ($this->getDefinitions() as $definition) {
+        foreach (array() as $definition) {
             if (isset($definition['hook']) && $definition['hook'] === $hook) {
                 (yield fn(&...$args): Event => $this->createInstance($definition['id'], $args));
             }

26) src/HookEventPluginManager.php:59 [M] Identical

--- Original
+++ New
@@ @@
     public function getHookEventFactories(string $hook) : \Generator
     {
         foreach ($this->getDefinitions() as $definition) {
-            if (isset($definition['hook']) && $definition['hook'] === $hook) {
+            if (isset($definition['hook']) && $definition['hook'] !== $hook) {
                 (yield fn(&...$args): Event => $this->createInstance($definition['id'], $args));
             }
         }

27) src/HookEventPluginManager.php:59 [M] LogicalAnd

--- Original
+++ New
@@ @@
     public function getHookEventFactories(string $hook) : \Generator
     {
         foreach ($this->getDefinitions() as $definition) {
-            if (isset($definition['hook']) && $definition['hook'] === $hook) {
+            if (isset($definition['hook']) || $definition['hook'] === $hook) {
                 (yield fn(&...$args): Event => $this->createInstance($definition['id'], $args));
             }
         }

28) src/HookEventPluginManager.php:69 [M] Foreach_

--- Original
+++ New
@@ @@
      */
     public function getAlterEventFactories(string $alter) : \Generator
     {
-        foreach ($this->getDefinitions() as $definition) {
+        foreach (array() as $definition) {
             if (isset($definition['alter']) && $definition['alter'] === $alter) {
                 (yield fn(&...$args): Event => $this->createInstance($definition['id'], $args));
             }

29) src/HookEventPluginManager.php:70 [M] Identical

--- Original
+++ New
@@ @@
     public function getAlterEventFactories(string $alter) : \Generator
     {
         foreach ($this->getDefinitions() as $definition) {
-            if (isset($definition['alter']) && $definition['alter'] === $alter) {
+            if (isset($definition['alter']) && $definition['alter'] !== $alter) {
                 (yield fn(&...$args): Event => $this->createInstance($definition['id'], $args));
             }
         }
     }
 }

30) src/HookEventPluginManager.php:70 [M] LogicalAnd

--- Original
+++ New
@@ @@
     public function getAlterEventFactories(string $alter) : \Generator
     {
         foreach ($this->getDefinitions() as $definition) {
-            if (isset($definition['alter']) && $definition['alter'] === $alter) {
+            if (isset($definition['alter']) || $definition['alter'] === $alter) {
                 (yield fn(&...$args): Event => $this->createInstance($definition['id'], $args));
             }
         }
     }
 }

31) src/Manager/HookEventDispatcherManager.php:30 [M] InstanceOf_

--- Original
+++ New
@@ @@
      */
     public function register(EventInterface $event) : Event
     {
-        assert($event instanceof Event);
+        assert(true);
         if ($event->isPropagationStopped()) {
             return $event;
         }

32) src/Manager/HookEventDispatcherManager.php:30 [M] InstanceOf_

--- Original
+++ New
@@ @@
      */
     public function register(EventInterface $event) : Event
     {
-        assert($event instanceof Event);
+        assert(false);
         if ($event->isPropagationStopped()) {
             return $event;
         }

33) src/ProxyClass/HookEventPluginManager.php:63 [M] LogicalNot

--- Original
+++ New
@@ @@
      */
     protected function lazyLoadItself()
     {
-        if (!isset($this->service)) {
+        if (isset($this->service)) {
             $this->service = $this->container->get($this->drupalProxyOriginalServiceId);
         }
         return $this->service;

User interface changes

API changes

Data model changes

📌 Task
Status

Active

Version

4.0

Component

Code

Created by

🇮🇩Indonesia el7cosmos 🇮🇩 GMT+7

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024