Skip to content

Commit ede8f6f

Browse files
committed
Type Comments array
1 parent 56a99f5 commit ede8f6f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/Comments.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,21 @@
1313
* Class to manage the comments of a translation.
1414
*
1515
* @phpstan-consistent-constructor
16+
*
17+
* @phpstan-type CommentsType array<int, string>
18+
*
19+
* @implements IteratorAggregate<int, string>
1620
*/
1721
class Comments implements JsonSerializable, Countable, IteratorAggregate
1822
{
23+
/**
24+
* @var CommentsType
25+
*/
1926
protected $comments = [];
2027

28+
/**
29+
* @param array{comments: CommentsType} $state
30+
*/
2131
public static function __set_state(array $state): Comments
2232
{
2333
return new static(...$state['comments']);
@@ -51,9 +61,7 @@ public function delete(string ...$comments): self
5161
foreach ($comments as $comment) {
5262
$key = array_search($comment, $this->comments);
5363

54-
if (is_int($key)) {
55-
array_splice($this->comments, $key, 1);
56-
}
64+
array_splice($this->comments, $key, 1);
5765
}
5866

5967
return $this;
@@ -76,6 +84,9 @@ public function count(): int
7684
return count($this->comments);
7785
}
7886

87+
/**
88+
* @return CommentsType
89+
*/
7990
public function toArray(): array
8091
{
8192
return $this->comments;

0 commit comments

Comments
 (0)