Skip to content

Commit da5450b

Browse files
committed
Add type annotations for Commentable
Also copy these type annotations to the implementing classes.
1 parent ddf0daa commit da5450b

File tree

5 files changed

+58
-11
lines changed

5 files changed

+58
-11
lines changed

src/CSSList/CSSList.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
abstract class CSSList implements Renderable, Commentable
3333
{
3434
/**
35-
* @var array<array-key, Comment> $aComments
35+
* @var array<array-key, Comment>
3636
*/
3737
protected $aComments;
3838

@@ -57,10 +57,10 @@ public function __construct($iLineNo = 0)
5757
}
5858

5959
/**
60-
* @throws SourceException
61-
* @throws UnexpectedTokenException
62-
*
6360
* @return void
61+
*
62+
* @throws UnexpectedTokenException
63+
* @throws SourceException
6464
*/
6565
public static function parseList(ParserState $oParserState, CSSList $oList)
6666
{
@@ -451,6 +451,8 @@ public function getContents()
451451

452452
/**
453453
* @param array<array-key, Comment> $aComments
454+
*
455+
* @return void
454456
*/
455457
public function addComments(array $aComments)
456458
{
@@ -467,6 +469,8 @@ public function getComments()
467469

468470
/**
469471
* @param array<array-key, Comment> $aComments
472+
*
473+
* @return void
470474
*/
471475
public function setComments(array $aComments)
472476
{

src/Comment/Commentable.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,21 @@
55
interface Commentable
66
{
77
/**
8-
* @param array $aComments Array of comments.
8+
* @param array<array-key, Comment> $aComments
9+
*
10+
* @return void
911
*/
1012
public function addComments(array $aComments);
1113

1214
/**
13-
* @return array
15+
* @return array<array-key, Comment>
1416
*/
1517
public function getComments();
1618

1719
/**
18-
* @param array $aComments Array containing Comment objects.
20+
* @param array<array-key, Comment> $aComments
21+
*
22+
* @return void
1923
*/
2024
public function setComments(array $aComments);
2125
}

src/Property/CSSNamespace.php

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

33
namespace Sabberworm\CSS\Property;
44

5+
use Sabberworm\CSS\Comment\Comment;
56
use Sabberworm\CSS\OutputFormat;
67

78
/**
@@ -15,6 +16,9 @@ class CSSNamespace implements AtRule
1516

1617
private $iLineNo;
1718

19+
/**
20+
* @var array<array-key, Comment>
21+
*/
1822
protected $aComments;
1923

2024
public function __construct($mUrl, $sPrefix = null, $iLineNo = 0)
@@ -89,16 +93,29 @@ public function atRuleArgs()
8993
return $aResult;
9094
}
9195

96+
/**
97+
* @param array<array-key, Comment> $aComments
98+
*
99+
* @return void
100+
*/
92101
public function addComments(array $aComments)
93102
{
94103
$this->aComments = array_merge($this->aComments, $aComments);
95104
}
96105

106+
/**
107+
* @return array<array-key, Comment>
108+
*/
97109
public function getComments()
98110
{
99111
return $this->aComments;
100112
}
101113

114+
/**
115+
* @param array<array-key, Comment> $aComments
116+
*
117+
* @return void
118+
*/
102119
public function setComments(array $aComments)
103120
{
104121
$this->aComments = $aComments;

src/Property/Import.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Sabberworm\CSS\Property;
44

5+
use Sabberworm\CSS\Comment\Comment;
56
use Sabberworm\CSS\OutputFormat;
67
use Sabberworm\CSS\Value\URL;
78

@@ -26,7 +27,7 @@ class Import implements AtRule
2627
protected $iLineNo;
2728

2829
/**
29-
* @var array
30+
* @var array<array-key, Comment>
3031
*/
3132
protected $aComments;
3233

@@ -97,16 +98,29 @@ public function atRuleArgs()
9798
return $aResult;
9899
}
99100

101+
/**
102+
* @param array<array-key, Comment> $aComments
103+
*
104+
* @return void
105+
*/
100106
public function addComments(array $aComments)
101107
{
102108
$this->aComments = array_merge($this->aComments, $aComments);
103109
}
104110

111+
/**
112+
* @return array<array-key, Comment>
113+
*/
105114
public function getComments()
106115
{
107116
return $this->aComments;
108117
}
109118

119+
/**
120+
* @param array<array-key, Comment> $aComments
121+
*
122+
* @return void
123+
*/
110124
public function setComments(array $aComments)
111125
{
112126
$this->aComments = $aComments;

src/RuleSet/RuleSet.php

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

33
namespace Sabberworm\CSS\RuleSet;
44

5+
use Sabberworm\CSS\Comment\Comment;
56
use Sabberworm\CSS\Comment\Commentable;
67
use Sabberworm\CSS\OutputFormat;
78
use Sabberworm\CSS\Parsing\ParserState;
@@ -19,6 +20,9 @@ abstract class RuleSet implements Renderable, Commentable
1920

2021
protected $iLineNo;
2122

23+
/**
24+
* @var array<array-key, Comment>
25+
*/
2226
protected $aComments;
2327

2428
public function __construct($iLineNo = 0)
@@ -265,23 +269,27 @@ public function render(OutputFormat $oOutputFormat)
265269
}
266270

267271
/**
268-
* @param array $aComments Array of comments.
272+
* @param array<array-key, Comment> $aComments
273+
*
274+
* @return void
269275
*/
270276
public function addComments(array $aComments)
271277
{
272278
$this->aComments = array_merge($this->aComments, $aComments);
273279
}
274280

275281
/**
276-
* @return array
282+
* @return array<array-key, Comment>
277283
*/
278284
public function getComments()
279285
{
280286
return $this->aComments;
281287
}
282288

283289
/**
284-
* @param array $aComments Array containing Comment objects.
290+
* @param array<array-key, Comment> $aComments
291+
*
292+
* @return void
285293
*/
286294
public function setComments(array $aComments)
287295
{

0 commit comments

Comments
 (0)