File tree 1 file changed +14
-3
lines changed
1 file changed +14
-3
lines changed Original file line number Diff line number Diff line change 13
13
* Class to manage the comments of a translation.
14
14
*
15
15
* @phpstan-consistent-constructor
16
+ *
17
+ * @phpstan-type CommentsType array<int, string>
18
+ *
19
+ * @implements IteratorAggregate<int, string>
16
20
*/
17
21
class Comments implements JsonSerializable, Countable, IteratorAggregate
18
22
{
23
+ /**
24
+ * @var CommentsType
25
+ */
19
26
protected $ comments = [];
20
27
28
+ /**
29
+ * @param array{comments: CommentsType} $state
30
+ */
21
31
public static function __set_state (array $ state ): Comments
22
32
{
23
33
return new static (...$ state ['comments ' ]);
@@ -51,9 +61,7 @@ public function delete(string ...$comments): self
51
61
foreach ($ comments as $ comment ) {
52
62
$ key = array_search ($ comment , $ this ->comments );
53
63
54
- if (is_int ($ key )) {
55
- array_splice ($ this ->comments , $ key , 1 );
56
- }
64
+ array_splice ($ this ->comments , $ key , 1 );
57
65
}
58
66
59
67
return $ this ;
@@ -76,6 +84,9 @@ public function count(): int
76
84
return count ($ this ->comments );
77
85
}
78
86
87
+ /**
88
+ * @return CommentsType
89
+ */
79
90
public function toArray (): array
80
91
{
81
92
return $ this ->comments ;
You can’t perform that action at this time.
0 commit comments