Problem/Motivation
I got this error for the Drupal 10 and php 8.1
TypeError: Drupal\core_event_dispatcher\Event\Entity\EntityFieldAccessEvent::getItems(): Return value must be of type Drupal\Core\Field\FieldItemListInterface, null returned in Drupal\core_event_dispatcher\Event\Entity\EntityFieldAccessEvent->getItems() (line 72 of modules/contrib/hook_event_dispatcher/modules/core_event_dispatcher/src/Event/Entity/EntityFieldAccessEvent.php).
In the class construct this parameter is allowed to be optional.
So in order to resolve this issue need to allow return null for this function
/**
* Get the items.
*
* @return null|\Drupal\Core\Field\FieldItemListInterface
* The items.
*/
public function getItems(): ?FieldItemListInterface {
return $this->items;
}
Issue fork hook_event_dispatcher-3377519
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
lysenkoComment #3
lysenkoComment #4
lysenkoComment #6
lysenkoComment #7
el7cosmosThanks, Lysenko. Are you able to add a test case in
\Drupal\Tests\core_event_dispatcher\Kernel\Entity\EntityFieldAccessEventTest?Comment #8
el7cosmosComment #9
el7cosmosComment #11
el7cosmos