Skip to content

Commit 4f802f4

Browse files
authored
Merge pull request #294 from oliverklee/task/types-commentable
2 parents 4113fc3 + 904340e commit 4f802f4

File tree

6 files changed

+87
-11
lines changed

6 files changed

+87
-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/Property/Selector.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,30 @@ class Selector
6060
)$
6161
/ux';
6262

63+
/**
64+
* @var string
65+
*/
6366
private $sSelector;
6467

68+
/**
69+
* @var int|null
70+
*/
6571
private $iSpecificity;
6672

73+
/**
74+
* @param string $sSelector
75+
*
76+
* @return bool
77+
*/
6778
public static function isValid($sSelector)
6879
{
6980
return preg_match(static::SELECTOR_VALIDATION_RX, $sSelector);
7081
}
7182

83+
/**
84+
* @param string $sSelector
85+
* @param bool $bCalculateSpecificity
86+
*/
7287
public function __construct($sSelector, $bCalculateSpecificity = false)
7388
{
7489
$this->setSelector($sSelector);
@@ -77,22 +92,36 @@ public function __construct($sSelector, $bCalculateSpecificity = false)
7792
}
7893
}
7994

95+
/**
96+
* @return string
97+
*/
8098
public function getSelector()
8199
{
82100
return $this->sSelector;
83101
}
84102

103+
/**
104+
* @param string $sSelector
105+
*
106+
* @return void
107+
*/
85108
public function setSelector($sSelector)
86109
{
87110
$this->sSelector = trim($sSelector);
88111
$this->iSpecificity = null;
89112
}
90113

114+
/**
115+
* @return string
116+
*/
91117
public function __toString()
92118
{
93119
return $this->getSelector();
94120
}
95121

122+
/**
123+
* @return int
124+
*/
96125
public function getSpecificity()
97126
{
98127
if ($this->iSpecificity === null) {

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)