Skip to content

Commit 5995dad

Browse files
authored
Merge pull request #433 from jacktonkin/generic-field-stubs
Generic FieldItemListInterface and related stubs
2 parents 87e64fb + 76027d6 commit 5995dad

16 files changed

+80
-12
lines changed

stubs/Drupal/Core/Entity/FieldableEntityInterface.stub

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,11 @@ namespace Drupal\Core\Entity;
44

55
interface FieldableEntityInterface extends EntityInterface {
66

7+
/**
8+
* @return \Drupal\Core\Field\FieldItemListInterface<\Drupal\Core\Field\FieldItemInterface>
9+
*/
10+
public function get(string $field_name);
11+
712
/**
813
* @return array<string, \Drupal\Core\Field\FieldDefinitionInterface>
914
*/
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?php
2+
3+
namespace Drupal\Core\Field;
4+
5+
use Drupal\Core\Entity\EntityInterface;
6+
use Drupal\Core\Field\Plugin\Field\FieldType\EntityReferenceItem;
7+
8+
/**
9+
* @template T of EntityInterface
10+
* @extends FieldItemListInterface<EntityReferenceItem<T>>
11+
* @property int|string|null $target_id
12+
* @property ?T $entity
13+
*/
14+
interface EntityReferenceFieldItemListInterface extends FieldItemListInterface {
15+
16+
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Drupal\Core\Field;
4+
5+
use Drupal\Core\Access\AccessibleInterface;
6+
use Drupal\Core\TypedData\ListInterface;
7+
8+
/**
9+
* @template T of FieldItemInterface
10+
* @extends ListInterface<T>
11+
* @property mixed $value
12+
*/
13+
interface FieldItemListInterface extends ListInterface {
14+
15+
}

stubs/Drupal/Core/Field/Plugin/Field/FieldItemListInterface.stub

Lines changed: 0 additions & 7 deletions
This file was deleted.

stubs/Drupal/Core/Field/Plugin/Field/FieldType/EntityReferenceItem.stub

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface;
77
use Drupal\Core\TypedData\OptionsProviderInterface;
88

99
/**
10-
* @property string|integer $target_id
11-
* @property \Drupal\Core\Entity\EntityInterface|null $entity
10+
* @template T of \Drupal\Core\Entity\EntityInterface
11+
* @property ?T $entity
12+
* @property string|int|null $target_id
1213
*/
1314
class EntityReferenceItem extends FieldItemBase implements OptionsProviderInterface, PreconfiguredFieldUiOptionsInterface {
1415
}
File renamed without changes.

stubs/Drupal/Core/TypedData/ComplexDataInterface.stub

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22

33
namespace Drupal\Core\TypedData;
44

5+
/**
6+
* @extends TraversableTypedDataInterface<string, TypedDataInterface>
7+
*/
58
interface ComplexDataInterface extends TraversableTypedDataInterface {
69
}

0 commit comments

Comments
 (0)