Skip to content

Commit 6e43258

Browse files
authored
[TASK] Use native type declarations for Renderable (#891)
1 parent a9eaea4 commit 6e43258

31 files changed

+60
-72
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Please also have a look at our
2424
- Only allow `string` for some `OutputFormat` properties (#885)
2525
- Make all non-private properties `@internal` (#886)
2626
- Use more native type declarations and strict mode
27-
(#641, #772, #774, #778, #804, #841, #873, #875)
27+
(#641, #772, #774, #778, #804, #841, #873, #875, #891)
2828
- Add visibility to all class/interface constants (#469)
2929

3030
### Deprecated

src/CSSList/AtRuleBlockList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class AtRuleBlockList extends CSSBlockList implements AtRule
2525
/**
2626
* @param string $type
2727
* @param string $arguments
28-
* @param int $lineNumber
28+
* @param int<0, max> $lineNumber
2929
*/
3030
public function __construct($type, $arguments = '', $lineNumber = 0)
3131
{

src/CSSList/CSSBlockList.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
abstract class CSSBlockList extends CSSList
2222
{
2323
/**
24-
* @param int $lineNumber
24+
* @param int<0, max> $lineNumber
2525
*/
2626
public function __construct($lineNumber = 0)
2727
{

src/CSSList/CSSList.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,14 @@ abstract class CSSList implements Renderable, Commentable
4848
protected $contents;
4949

5050
/**
51-
* @var int
51+
* @var int<0, max>
5252
*
5353
* @internal since 8.8.0
5454
*/
5555
protected $lineNumber;
5656

5757
/**
58-
* @param int $lineNumber
58+
* @param int<0, max> $lineNumber
5959
*/
6060
public function __construct($lineNumber = 0)
6161
{
@@ -255,9 +255,9 @@ private static function identifierIs($identifier, string $match): bool
255255
}
256256

257257
/**
258-
* @return int
258+
* @return int<0, max>
259259
*/
260-
public function getLineNo()
260+
public function getLineNo(): int
261261
{
262262
return $this->lineNumber;
263263
}

src/CSSList/Document.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
class Document extends CSSBlockList
2020
{
2121
/**
22-
* @param int $lineNumber
22+
* @param int<0, max> $lineNumber
2323
*/
2424
public function __construct($lineNumber = 0)
2525
{

src/CSSList/KeyFrame.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class KeyFrame extends CSSList implements AtRule
2020
private $animationName;
2121

2222
/**
23-
* @param int $lineNumber
23+
* @param int<0, max> $lineNumber
2424
*/
2525
public function __construct($lineNumber = 0)
2626
{

src/Comment/Comment.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
class Comment implements Renderable
1111
{
1212
/**
13-
* @var int
13+
* @var int<0, max>
1414
*
1515
* @internal since 8.8.0
1616
*/
@@ -25,7 +25,7 @@ class Comment implements Renderable
2525

2626
/**
2727
* @param string $commentText
28-
* @param int $lineNumber
28+
* @param int<0, max> $lineNumber
2929
*/
3030
public function __construct($commentText = '', $lineNumber = 0)
3131
{
@@ -42,9 +42,9 @@ public function getComment()
4242
}
4343

4444
/**
45-
* @return int
45+
* @return int<0, max>
4646
*/
47-
public function getLineNo()
47+
public function getLineNo(): int
4848
{
4949
return $this->lineNumber;
5050
}

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class Parser
2020

2121
/**
2222
* @param string $sText the complete CSS as text (i.e., usually the contents of a CSS file)
23-
* @param int $lineNumber the line number (starting from 1, not from 0)
23+
* @param int<0, max> $lineNumber the line number (starting from 1, not from 0)
2424
*/
2525
public function __construct($sText, ?Settings $oParserSettings = null, $lineNumber = 1)
2626
{

src/Parsing/OutputException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ final class OutputException extends SourceException
1111
{
1212
/**
1313
* @param string $sMessage
14-
* @param int $lineNumber
14+
* @param int<0, max> $lineNumber
1515
*/
1616
public function __construct($sMessage, $lineNumber = 0)
1717
{

src/Parsing/ParserState.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class ParserState
5858

5959
/**
6060
* @param string $sText the complete CSS as text (i.e., usually the contents of a CSS file)
61-
* @param int $lineNumber
61+
* @param int<0, max> $lineNumber
6262
*/
6363
public function __construct($sText, Settings $oParserSettings, $lineNumber = 1)
6464
{

src/Parsing/SourceException.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class SourceException extends \Exception
1313

1414
/**
1515
* @param string $sMessage
16-
* @param int $lineNumber
16+
* @param int<0, max> $lineNumber
1717
*/
1818
public function __construct($sMessage, $lineNumber = 0)
1919
{
@@ -25,9 +25,9 @@ public function __construct($sMessage, $lineNumber = 0)
2525
}
2626

2727
/**
28-
* @return int
28+
* @return int<0, max>
2929
*/
30-
public function getLineNo()
30+
public function getLineNo(): int
3131
{
3232
return $this->lineNumber;
3333
}

src/Parsing/UnexpectedTokenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class UnexpectedTokenException extends SourceException
3030
* @param string $sExpected
3131
* @param string $sFound
3232
* @param string $sMatchType
33-
* @param int $lineNumber
33+
* @param int<0, max> $lineNumber
3434
*/
3535
public function __construct($sExpected, $sFound, $sMatchType = 'literal', $lineNumber = 0)
3636
{

src/Property/CSSNamespace.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class CSSNamespace implements AtRule
3737
/**
3838
* @param string $mUrl
3939
* @param string|null $sPrefix
40-
* @param int $lineNumber
40+
* @param int<0, max> $lineNumber
4141
*/
4242
public function __construct($mUrl, $sPrefix = null, $lineNumber = 0)
4343
{
@@ -48,9 +48,9 @@ public function __construct($mUrl, $sPrefix = null, $lineNumber = 0)
4848
}
4949

5050
/**
51-
* @return int
51+
* @return int<0, max>
5252
*/
53-
public function getLineNo()
53+
public function getLineNo(): int
5454
{
5555
return $this->lineNumber;
5656
}

src/Property/Charset.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Charset implements AtRule
2424
private $oCharset;
2525

2626
/**
27-
* @var int
27+
* @var int<0, max>
2828
*
2929
* @internal since 8.8.0
3030
*/
@@ -38,7 +38,7 @@ class Charset implements AtRule
3838
protected $comments;
3939

4040
/**
41-
* @param int $lineNumber
41+
* @param int<0, max> $lineNumber
4242
*/
4343
public function __construct(CSSString $oCharset, $lineNumber = 0)
4444
{
@@ -48,9 +48,9 @@ public function __construct(CSSString $oCharset, $lineNumber = 0)
4848
}
4949

5050
/**
51-
* @return int
51+
* @return int<0, max>
5252
*/
53-
public function getLineNo()
53+
public function getLineNo(): int
5454
{
5555
return $this->lineNumber;
5656
}

src/Property/Import.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Import implements AtRule
2424
private $mediaQuery;
2525

2626
/**
27-
* @var int
27+
* @var int<0, max>
2828
*
2929
* @internal since 8.8.0
3030
*/
@@ -39,7 +39,7 @@ class Import implements AtRule
3939

4040
/**
4141
* @param string $mediaQuery
42-
* @param int $lineNumber
42+
* @param int<0, max> $lineNumber
4343
*/
4444
public function __construct(URL $location, $mediaQuery, $lineNumber = 0)
4545
{
@@ -50,9 +50,9 @@ public function __construct(URL $location, $mediaQuery, $lineNumber = 0)
5050
}
5151

5252
/**
53-
* @return int
53+
* @return int<0, max>
5454
*/
55-
public function getLineNo()
55+
public function getLineNo(): int
5656
{
5757
return $this->lineNumber;
5858
}

src/Renderable.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,12 @@
66

77
interface Renderable
88
{
9-
/**
10-
* @return string
11-
*/
12-
public function __toString();
9+
public function __toString(): string;
1310

14-
/**
15-
* @return string
16-
*/
17-
public function render(OutputFormat $oOutputFormat);
11+
public function render(OutputFormat $oOutputFormat): string;
1812

1913
/**
20-
* @return int
14+
* @return int<0, max>
2115
*/
22-
public function getLineNo();
16+
public function getLineNo(): int;
2317
}

src/Rule/Rule.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ class Rule implements Renderable, Commentable
6262

6363
/**
6464
* @param string $sRule
65-
* @param int $lineNumber
65+
* @param int<0, max> $lineNumber
6666
* @param int $iColNo
6767
*/
6868
public function __construct($sRule, $lineNumber = 0, $iColNo = 0)
@@ -141,9 +141,9 @@ private static function listDelimiterForRule($sRule): array
141141
}
142142

143143
/**
144-
* @return int
144+
* @return int<0, max>
145145
*/
146-
public function getLineNo()
146+
public function getLineNo(): int
147147
{
148148
return $this->lineNumber;
149149
}

src/RuleSet/AtRuleSet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class AtRuleSet extends RuleSet implements AtRule
2828
/**
2929
* @param string $sType
3030
* @param string $sArgs
31-
* @param int $lineNumber
31+
* @param int<0, max> $lineNumber
3232
*/
3333
public function __construct($sType, $sArgs = '', $lineNumber = 0)
3434
{

src/RuleSet/DeclarationBlock.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class DeclarationBlock extends RuleSet
3030
private $aSelectors;
3131

3232
/**
33-
* @param int $lineNumber
33+
* @param int<0, max> $lineNumber
3434
*/
3535
public function __construct($lineNumber = 0)
3636
{

src/RuleSet/RuleSet.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ abstract class RuleSet implements Renderable, Commentable
3030
private $aRules;
3131

3232
/**
33-
* @var int
33+
* @var int<0, max>
3434
*
3535
* @internal since 8.8.0
3636
*/
@@ -44,7 +44,7 @@ abstract class RuleSet implements Renderable, Commentable
4444
protected $comments;
4545

4646
/**
47-
* @param int $lineNumber
47+
* @param int<0, max> $lineNumber
4848
*/
4949
public function __construct($lineNumber = 0)
5050
{
@@ -94,9 +94,9 @@ public static function parseRuleSet(ParserState $parserState, RuleSet $ruleSet):
9494
}
9595

9696
/**
97-
* @return int
97+
* @return int<0, max>
9898
*/
99-
public function getLineNo()
99+
public function getLineNo(): int
100100
{
101101
return $this->lineNumber;
102102
}

src/Value/CSSFunction.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CSSFunction extends ValueList
2424
* @param string $sName
2525
* @param RuleValueList|array<array-key, Value|string> $aArguments
2626
* @param string $sSeparator
27-
* @param int $lineNumber
27+
* @param int<0, max> $lineNumber
2828
*/
2929
public function __construct($sName, $aArguments, $sSeparator = ',', $lineNumber = 0)
3030
{

src/Value/CSSString.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class CSSString extends PrimitiveValue
2424

2525
/**
2626
* @param string $sString
27-
* @param int $lineNumber
27+
* @param int<0, max> $lineNumber
2828
*/
2929
public function __construct($sString, $lineNumber = 0)
3030
{

src/Value/CalcRuleValueList.php

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,14 @@
99
class CalcRuleValueList extends RuleValueList
1010
{
1111
/**
12-
* @param int $lineNumber
12+
* @param int<0, max> $lineNumber
1313
*/
1414
public function __construct($lineNumber = 0)
1515
{
1616
parent::__construct(',', $lineNumber);
1717
}
1818

19-
/**
20-
* @return string
21-
*/
22-
public function render(OutputFormat $oOutputFormat)
19+
public function render(OutputFormat $oOutputFormat): string
2320
{
2421
return $oOutputFormat->implode(' ', $this->aComponents);
2522
}

src/Value/Color.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ class Color extends CSSFunction
1717
{
1818
/**
1919
* @param array<array-key, Value|string> $colorValues
20-
* @param int $lineNumber
20+
* @param int<0, max> $lineNumber
2121
*/
2222
public function __construct(array $colorValues, $lineNumber = 0)
2323
{

src/Value/LineName.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class LineName extends ValueList
1313
{
1414
/**
1515
* @param array<int, Value|string> $aComponents
16-
* @param int $lineNumber
16+
* @param int<0, max> $lineNumber
1717
*/
1818
public function __construct(array $aComponents = [], $lineNumber = 0)
1919
{

src/Value/PrimitiveValue.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
abstract class PrimitiveValue extends Value
88
{
99
/**
10-
* @param int $lineNumber
10+
* @param int<0, max> $lineNumber
1111
*/
1212
public function __construct($lineNumber = 0)
1313
{

0 commit comments

Comments
 (0)