Skip to content

Commit 84fe196

Browse files
ceesgeenemglaman
andauthored
Add stubs for comment field type (#784)
* Add stubs for comment field type * Update stubs/Drupal/comment/Plugin/Field/FieldType/CommentItem.stub --------- Co-authored-by: Matt Glaman <[email protected]>
1 parent 7a0b022 commit 84fe196

File tree

3 files changed

+34
-0
lines changed

3 files changed

+34
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?php
2+
3+
namespace Drupal\comment\Plugin\Field\FieldType;
4+
5+
use Drupal\Core\Field\FieldItemBase;
6+
7+
/**
8+
* @property ?int $status
9+
* @property ?int $cid
10+
* @property ?int $last_comment_timestamp
11+
* @property ?string $last_comment_name
12+
* @property ?int $last_comment_uid
13+
* @property ?int $comment_count
14+
*/
15+
class CommentItem extends FieldItemBase implements CommentItemInterface {
16+
17+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
namespace Drupal\comment\Plugin\Field\FieldType;
4+
5+
interface CommentItemInterface {
6+
}

tests/src/Type/data/field-types.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace DrupalEntityFields;
44

5+
use Drupal\comment\Plugin\Field\FieldType\CommentItem;
56
use Drupal\Core\Field\Plugin\Field\FieldType\BooleanItem;
67
use Drupal\Core\Field\Plugin\Field\FieldType\ChangedItem;
78
use Drupal\Core\Field\Plugin\Field\FieldType\CreatedItem;
@@ -30,6 +31,16 @@
3031

3132
$node = Node::create(['type' => 'page']);
3233

34+
// CommentItem.
35+
$comment_field = $node->get('field_comment')->first();
36+
assert($comment_field instanceof CommentItem);
37+
assertType(CommentItem::class, $comment_field);
38+
assertType('int|null', $comment_field->status);
39+
assertType('int|null', $comment_field->cid);
40+
assertType('int|null', $comment_field->last_comment_timestamp);
41+
assertType('string|null', $comment_field->last_comment_name);
42+
assertType('int|null', $comment_field->comment_count);
43+
3344
// LinkItem.
3445
$link_field = $node->get('field_link')->first();
3546
assert($link_field instanceof LinkItem);

0 commit comments

Comments
 (0)