Skip to content

Commit 34cad6b

Browse files
authored
Merge pull request #505 from mglaman/gh499
2 parents fdc9f57 + 82a789c commit 34cad6b

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
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\TypedData\Plugin\DataType\ItemList;
6+
7+
class FieldItemList extends ItemList implements FieldItemListInterface {
8+
9+
/**
10+
* @return \Drupal\Core\Field\FieldItemInterface
11+
*/
12+
protected function createItem($offset = 0, $value = NULL): \Drupal\Core\Field\FieldItemInterface {
13+
}
14+
15+
}

tests/src/Type/EntityTypesTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ final class EntityTypesTest extends TypeInferenceTestCase
1414
public function dataFileAsserts(): iterable
1515
{
1616
yield from $this->gatherAssertTypes(__DIR__ . '/data/entity-type-stubs.php');
17+
yield from $this->gatherAssertTypes(__DIR__ . '/data/bug-499.php');
1718
}
1819

1920
/**

tests/src/Type/data/bug-499.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Bug499;
4+
5+
use Drupal\Core\Field\FieldItemList;
6+
use Drupal\Core\TypedData\ComputedItemListTrait;
7+
use function PHPStan\Testing\assertType;
8+
9+
class ComputedFieldItemList extends FieldItemList {
10+
use ComputedItemListTrait;
11+
12+
protected function computeValue()
13+
{
14+
$item = $this->createItem(0, 'foo');
15+
assertType('Drupal\Core\Field\FieldItemInterface', $item);
16+
$this->list[0] = $item;
17+
}
18+
}

0 commit comments

Comments
 (0)