From 9ba6c3d1590412b32fb5a8d08bc99ff6675068ee Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Fri, 8 Jan 2021 19:44:15 +0000 Subject: [PATCH] CommentItem/HeadingItem: Make more constructor args required This ensures the getters always return the promised types. Change-Id: I1a3c909f5395463ef7a89d896ead1520b2a17509 --- includes/CommentItem.php | 6 +++--- tests/phpunit/ThreadItemTest.php | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/includes/CommentItem.php b/includes/CommentItem.php index b038cc1b9..f3b1fc43f 100644 --- a/includes/CommentItem.php +++ b/includes/CommentItem.php @@ -20,12 +20,12 @@ class CommentItem extends ThreadItem { * timestamps) for this comment. There is always at least one signature, but there may be * multiple. The author and timestamp of the comment is determined from the first signature. * The last node in every signature range is a node containing the timestamp. - * @param string|null $timestamp - * @param string|null $author Comment author's username + * @param string $timestamp + * @param string $author Comment author's username */ public function __construct( int $level, ImmutableRange $range, - array $signatureRanges = [], ?string $timestamp = null, ?string $author = null + array $signatureRanges, string $timestamp, string $author ) { parent::__construct( 'comment', $level, $range ); $this->signatureRanges = $signatureRanges; diff --git a/tests/phpunit/ThreadItemTest.php b/tests/phpunit/ThreadItemTest.php index 28cf193e5..4f7bd1c1d 100644 --- a/tests/phpunit/ThreadItemTest.php +++ b/tests/phpunit/ThreadItemTest.php @@ -25,8 +25,7 @@ class ThreadItemTest extends CommentTestCase { $makeThreadItem = function ( array $arr ) use ( &$makeThreadItem, $range ) : ThreadItem { if ( $arr['type'] === 'comment' ) { - $item = new CommentItem( 1, $range ); - $item->setAuthor( $arr['author'] ); + $item = new CommentItem( 1, $range, [], 'TIMESTAMP', $arr['author'] ); } else { $item = new HeadingItem( $range, 2 ); }