Skip to content

Commit 37cdb81

Browse files
authored
Merge pull request #286 from oliverklee/cleanup/type-parser
Add type annotations for `Parser`
2 parents 88eb050 + 50bf019 commit 37cdb81

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

src/Parser.php

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44

55
use Sabberworm\CSS\CSSList\Document;
66
use Sabberworm\CSS\Parsing\ParserState;
7+
use Sabberworm\CSS\Parsing\SourceException;
78

89
/**
9-
* Parser class parses CSS from text into a data structure.
10+
* This class parses CSS from text into a data structure.
1011
*/
1112
class Parser
1213
{
@@ -16,11 +17,9 @@ class Parser
1617
private $oParserState;
1718

1819
/**
19-
* Note that that iLineNo starts from 1 and not 0.
20-
*
21-
* @param $sText
20+
* @param string $sText
2221
* @param Settings|null $oParserSettings
23-
* @param int $iLineNo
22+
* @param int $iLineNo the line number (starting from 1, not from 0)
2423
*/
2524
public function __construct($sText, Settings $oParserSettings = null, $iLineNo = 1)
2625
{
@@ -30,20 +29,29 @@ public function __construct($sText, Settings $oParserSettings = null, $iLineNo =
3029
$this->oParserState = new ParserState($sText, $oParserSettings, $iLineNo);
3130
}
3231

32+
/**
33+
* @param string $sCharset
34+
*
35+
* @return void
36+
*/
3337
public function setCharset($sCharset)
3438
{
3539
$this->oParserState->setCharset($sCharset);
3640
}
3741

42+
/**
43+
* @return void
44+
*/
3845
public function getCharset()
3946
{
47+
// Note: The `return` statement is missing here. This is a bug that needs to be fixed.
4048
$this->oParserState->getCharset();
4149
}
4250

4351
/**
4452
* @return Document
4553
*
46-
* @throws Parsing\SourceException
54+
* @throws SourceException
4755
*/
4856
public function parse()
4957
{

0 commit comments

Comments
 (0)