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() (

Created on 27 July 2023, over 1 year ago
Updated 10 August 2023, over 1 year ago

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;
  }
🐛 Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

🇺🇦Ukraine Lysenko Ukraine, Lutsk

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

Comments & Activities

Production build 0.71.5 2024