Skip to content

Commit 192d004

Browse files
committed
Streamline the existing PHPDoc comments
Make them more useful for static code analysis, for human readers and for rendering.
1 parent d9ad684 commit 192d004

File tree

16 files changed

+100
-49
lines changed

16 files changed

+100
-49
lines changed

src/CSSList/CSSList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ private static function parseAtRule(ParserState $oParserState)
180180
}
181181
return new CSSNamespace($mUrl, $sPrefix, $iIdentifierLineNum);
182182
} else {
183-
//Unknown other at rule (font-face or such)
183+
// Unknown other at rule (font-face or such)
184184
$sArgs = trim($oParserState->consumeUntil('{', false, true));
185185
if (substr_count($sArgs, "(") != substr_count($sArgs, ")")) {
186186
if ($oParserState->getSettings()->bLenientParsing) {
@@ -282,7 +282,7 @@ public function remove($oItemToRemove)
282282
/**
283283
* Replaces an item from the CSS list.
284284
*
285-
* @param RuleSet|Import|Charset|CSSList $oItemToRemove
285+
* @param RuleSet|Import|Charset|CSSList $oOldItem
286286
* May be a RuleSet (most likely a DeclarationBlock), a Import, a Charset
287287
* or another CSSList (most likely a MediaQuery)
288288
*/

src/Comment/Comment.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public function getLineNo()
3434
}
3535

3636
/**
37-
* @return string
37+
* @param string $sComment
3838
*/
3939
public function setComment($sComment)
4040
{

src/OutputFormat.php

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,26 @@
1111
class OutputFormat
1212
{
1313
/**
14-
* Value format
14+
* Value format: `"` means double-quote, `'` means single-quote
15+
*
16+
* @var string
1517
*/
16-
// " means double-quote, ' means single-quote
1718
public $sStringQuotingType = '"';
1819

19-
// Output RGB colors in hash notation if possible
20+
/**
21+
* Output RGB colors in hash notation if possible
22+
*
23+
* @var string
24+
*/
2025
public $bRGBHashNotation = true;
2126

2227
/**
2328
* Declaration format
29+
*
30+
* Semicolon after the last rule of a declaration block can be omitted. To do that, set this false.
31+
*
32+
* @var bool
2433
*/
25-
// Semicolon after the last rule of a declaration block can be omitted. To do that, set this false.
2634
public $bSemicolonAfterLastRule = true;
2735

2836
/**
@@ -45,38 +53,57 @@ class OutputFormat
4553

4654
public $sSpaceBetweenBlocks = "\n";
4755

48-
// Content injected in and around @-rule blocks.
56+
/**
57+
* Content injected in and around @-rule blocks.
58+
*
59+
* @var string
60+
*/
4961
public $sBeforeAtRuleBlock = '';
5062

5163
public $sAfterAtRuleBlock = '';
5264

53-
// This is what’s printed before and after the comma if a declaration block contains multiple selectors.
65+
/**
66+
* This is what’s printed before and after the comma if a declaration block contains multiple selectors.
67+
*
68+
* @var string
69+
*/
5470
public $sSpaceBeforeSelectorSeparator = '';
5571

5672
public $sSpaceAfterSelectorSeparator = ' ';
5773

58-
// This is what’s printed after the comma of value lists
74+
/**
75+
* This is what’s printed after the comma of value lists
76+
*
77+
* @var string
78+
*/
5979
public $sSpaceBeforeListArgumentSeparator = '';
6080

6181
public $sSpaceAfterListArgumentSeparator = '';
6282

6383
public $sSpaceBeforeOpeningBrace = ' ';
6484

65-
// Content injected in and around declaration blocks.
85+
/**
86+
* Content injected in and around declaration blocks.
87+
*
88+
* @var string
89+
*/
6690
public $sBeforeDeclarationBlock = '';
6791

6892
public $sAfterDeclarationBlockSelectors = '';
6993

7094
public $sAfterDeclarationBlock = '';
7195

7296
/**
73-
* Indentation
97+
* Indentation character(s) per level. Only applicable if newlines are used in any of the spacing settings.
98+
*
99+
* @var string
74100
*/
75-
// Indentation character(s) per level. Only applicable if newlines are used in any of the spacing settings.
76101
public $sIndentation = "\t";
77102

78103
/**
79104
* Output exceptions.
105+
*
106+
* @var bool
80107
*/
81108
public $bIgnoreExceptions = false;
82109

src/OutputFormatter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,15 +99,15 @@ public function safely($cCode)
9999
return $cCode();
100100
} catch (OutputException $e) {
101101
return null;
102-
} //Do nothing
102+
} // Do nothing
103103
} else {
104104
// Run the code as-is
105105
return $cCode();
106106
}
107107
}
108108

109109
/**
110-
* Clone of the implode function but calls ->render with the current output format instead of ` __toString()
110+
* Clone of the implode function but calls -> render with the current output format instead of `__toString()`
111111
*/
112112
public function implode($sSeparator, array $aValues, $bIncreaseLevel = false)
113113
{

src/Parser.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ class Parser
1616
private $oParserState;
1717

1818
/**
19-
* Parser constructor.
20-
* Note that that iLineNo starts from 1 and not 0
19+
* Note that that iLineNo starts from 1 and not 0.
2120
*
2221
* @param $sText
2322
* @param Settings|null $oParserSettings

src/Parsing/ParserState.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function parseCharacter($bIsForIdentifier)
100100
}
101101
$sUnicode = $this->consumeExpression('/^[0-9a-fA-F]{1,6}/u', 6);
102102
if ($this->strlen($sUnicode) < 6) {
103-
//Consume whitespace after incomplete unicode escape
103+
// Consume whitespace after incomplete unicode escape
104104
if (preg_match('/\\s/isSu', $this->peek())) {
105105
if ($this->comes('\r\n')) {
106106
$this->consume(2);

src/Property/AtRule.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ interface AtRule extends Renderable, Commentable
1010
// Since there are more set rules than block rules,
1111
// we’re whitelisting the block rules and have anything else be treated as a set rule.
1212
const BLOCK_RULES = 'media/document/supports/region-style/font-feature-values';
13-
// …and more font-specific ones (to be used inside font-feature-values)
13+
// … and more font-specific ones (to be used inside font-feature-values)
1414
const SET_RULES = 'font-face/counter-style/page/swash/styleset/annotation';
1515

1616
/**

src/Property/Import.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
use Sabberworm\CSS\Value\URL;
77

88
/**
9-
* Class representing an @import rule.
9+
* Class representing an `@import` rule.
1010
*/
1111
class Import implements AtRule
1212
{

src/Property/KeyframeSelector.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,11 @@
44

55
class KeyframeSelector extends Selector
66
{
7-
//Regexes for specificity calculations
8-
7+
/**
8+
* regexp for specificity calculations
9+
*
10+
* @var string
11+
*/
912
const SELECTOR_VALIDATION_RX = '/
1013
^(
1114
(?:

src/Property/Selector.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@
88
*/
99
class Selector
1010
{
11-
//Regexes for specificity calculations
11+
/**
12+
* regexp for specificity calculations
13+
*
14+
* @var string
15+
*/
1216
const NON_ID_ATTRIBUTES_AND_PSEUDO_CLASSES_RX = '/
1317
(\.[\w]+) # classes
1418
|
@@ -28,6 +32,11 @@ class Selector
2832
))
2933
/ix';
3034

35+
/**
36+
* regexp for specificity calculations
37+
*
38+
* @var string
39+
*/
3140
const ELEMENTS_AND_PSEUDO_ELEMENTS_RX = '/
3241
((^|[\s\+\>\~]+)[\w]+ # elements
3342
|
@@ -36,6 +45,11 @@ class Selector
3645
))
3746
/ix';
3847

48+
/**
49+
* regexp for specificity calculations
50+
*
51+
* @var string
52+
*/
3953
const SELECTOR_VALIDATION_RX = '/
4054
^(
4155
(?:

0 commit comments

Comments
 (0)