function ItemList::first

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::first()
  2. 10 core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::first()
  3. 9 core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::first()
  4. 8.9.x core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php \Drupal\Core\TypedData\Plugin\DataType\ItemList::first()

Returns the first item in this list.

@phpstan-return ?T

Return value

\Drupal\Core\TypedData\TypedDataInterface|null The first item in this list, or NULL if there are no items.

Overrides ListInterface::first

5 calls to ItemList::first()
FieldItemList::applyDefaultValue in core/lib/Drupal/Core/Field/FieldItemList.php
FieldItemList::__get in core/lib/Drupal/Core/Field/FieldItemList.php
FieldItemList::__isset in core/lib/Drupal/Core/Field/FieldItemList.php
FieldItemList::__set in core/lib/Drupal/Core/Field/FieldItemList.php
FieldItemList::__unset in core/lib/Drupal/Core/Field/FieldItemList.php

File

core/lib/Drupal/Core/TypedData/Plugin/DataType/ItemList.php, line 171

Class

ItemList
A generic list class.

Namespace

Drupal\Core\TypedData\Plugin\DataType

Code

public function first() {
  return $this->get(0);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.