Skip to content

Commit 39a7c72

Browse files
committed
[BUGFIX] Ensure PHP 8.4 compatibility for nullable parameters
Ensure that parameters that have a `null` default value also have `null` as part of their type annotations. Also remove native type declarations for nullable parameters (as nullable parameters are not possible with some of the PHP versions we currently support). https://php.watch/versions/8.4/implicitly-marking-parameter-type-nullable-deprecated Fixes #634
1 parent 895f7ad commit 39a7c72

22 files changed

+60
-24
lines changed

src/CSSList/AtRuleBlockList.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,11 @@ public function __toString()
5757
}
5858

5959
/**
60+
* @param OutputFormat $oOutputFormat
61+
*
6062
* @return string
6163
*/
62-
public function render(OutputFormat $oOutputFormat)
64+
public function render($oOutputFormat)
6365
{
6466
$sResult = $oOutputFormat->comments($this);
6567
$sResult .= $oOutputFormat->sBeforeAtRuleBlock;

src/CSSList/CSSList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,8 @@ public function append($oItem)
286286
* Splices the list of contents.
287287
*
288288
* @param int $iOffset
289-
* @param int $iLength
290-
* @param array<int, RuleSet|CSSList|Import|Charset> $mReplacement
289+
* @param int|null $iLength
290+
* @param array<int, RuleSet|CSSList|Import|Charset>|null $mReplacement
291291
*
292292
* @return void
293293
*/

src/CSSList/Document.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function getAllRuleSets()
7878
/**
7979
* Returns all `Value` objects found recursively in `Rule`s in the tree.
8080
*
81-
* @param CSSList|RuleSet|string $mElement
81+
* @param CSSList|RuleSet|string|null $mElement
8282
* the `CSSList` or `RuleSet` to start the search from (defaults to the whole document).
8383
* If a string is given, it is used as rule name filter.
8484
* @param bool $bSearchInFunctionArguments whether to also return Value objects used as Function arguments.
@@ -155,7 +155,7 @@ public function createShorthands()
155155
*
156156
* @return string
157157
*/
158-
public function render(OutputFormat $oOutputFormat = null)
158+
public function render($oOutputFormat = null)
159159
{
160160
if ($oOutputFormat === null) {
161161
$oOutputFormat = new OutputFormat();

src/CSSList/KeyFrame.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,11 @@ public function __toString()
6868
}
6969

7070
/**
71+
* @param OutputFormat $oOutputFormat
72+
*
7173
* @return string
7274
*/
73-
public function render(OutputFormat $oOutputFormat)
75+
public function render($oOutputFormat)
7476
{
7577
$sResult = $oOutputFormat->comments($this);
7678
$sResult .= "@{$this->vendorKeyFrame} {$this->animationName}{$oOutputFormat->spaceBeforeOpeningBrace()}{";

src/Comment/Comment.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,11 @@ public function __toString()
6262
}
6363

6464
/**
65+
* @param OutputFormat $oOutputFormat
66+
*
6567
* @return string
6668
*/
67-
public function render(OutputFormat $oOutputFormat)
69+
public function render($oOutputFormat)
6870
{
6971
return '/*' . $this->sComment . '*/';
7072
}

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class Parser
2121
* @param Settings|null $oParserSettings
2222
* @param int $iLineNo the line number (starting from 1, not from 0)
2323
*/
24-
public function __construct($sText, Settings $oParserSettings = null, $iLineNo = 1)
24+
public function __construct($sText, $oParserSettings = null, $iLineNo = 1)
2525
{
2626
if ($oParserSettings === null) {
2727
$oParserSettings = Settings::create();

src/Property/CSSNamespace.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ public function __toString()
6060
}
6161

6262
/**
63+
* @param OutputFormat $oOutputFormat
64+
*
6365
* @return string
6466
*/
65-
public function render(OutputFormat $oOutputFormat)
67+
public function render($oOutputFormat)
6668
{
6769
return '@namespace ' . ($this->sPrefix === null ? '' : $this->sPrefix . ' ')
6870
. $this->mUrl->render($oOutputFormat) . ';';

src/Property/Charset.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,9 +78,11 @@ public function __toString()
7878
}
7979

8080
/**
81+
* @param OutputFormat $oOutputFormat
82+
*
8183
* @return string
8284
*/
83-
public function render(OutputFormat $oOutputFormat)
85+
public function render($oOutputFormat)
8486
{
8587
return "{$oOutputFormat->comments($this)}@charset {$this->oCharset->render($oOutputFormat)};";
8688
}

src/Property/Import.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,11 @@ public function __toString()
7979
}
8080

8181
/**
82+
* @param OutputFormat $oOutputFormat
83+
*
8284
* @return string
8385
*/
84-
public function render(OutputFormat $oOutputFormat)
86+
public function render($oOutputFormat)
8587
{
8688
return $oOutputFormat->comments($this) . "@import " . $this->oLocation->render($oOutputFormat)
8789
. ($this->sMediaQuery === null ? '' : ' ' . $this->sMediaQuery) . ';';

src/Renderable.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ interface Renderable
1010
public function __toString();
1111

1212
/**
13+
* @param OutputFormat $oOutputFormat
14+
*
1315
* @return string
1416
*/
15-
public function render(OutputFormat $oOutputFormat);
17+
public function render($oOutputFormat);
1618

1719
/**
1820
* @return int

src/Rule/Rule.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,9 +348,11 @@ public function __toString()
348348
}
349349

350350
/**
351+
* @param OutputFormat $oOutputFormat
352+
*
351353
* @return string
352354
*/
353-
public function render(OutputFormat $oOutputFormat)
355+
public function render($oOutputFormat)
354356
{
355357
$sResult = "{$oOutputFormat->comments($this)}{$this->sRule}:{$oOutputFormat->spaceAfterRuleName()}";
356358
if ($this->mValue instanceof Value) { // Can also be a ValueList

src/RuleSet/AtRuleSet.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ public function __toString()
6060
}
6161

6262
/**
63+
* @param OutputFormat $oOutputFormat
64+
*
6365
* @return string
6466
*/
65-
public function render(OutputFormat $oOutputFormat)
67+
public function render($oOutputFormat)
6668
{
6769
$sResult = $oOutputFormat->comments($this);
6870
$sArgs = $this->sArgs;

src/RuleSet/DeclarationBlock.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -810,11 +810,13 @@ public function __toString()
810810
}
811811

812812
/**
813+
* @param OutputFormat $oOutputFormat
814+
*
813815
* @return string
814816
*
815817
* @throws OutputException
816818
*/
817-
public function render(OutputFormat $oOutputFormat)
819+
public function render($oOutputFormat)
818820
{
819821
$sResult = $oOutputFormat->comments($this);
820822
if (count($this->aSelectors) === 0) {

src/RuleSet/RuleSet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public function getLineNo()
102102
*
103103
* @return void
104104
*/
105-
public function addRule(Rule $oRule, Rule $oSibling = null)
105+
public function addRule(Rule $oRule, $oSibling = null)
106106
{
107107
$sRule = $oRule->getRule();
108108
if (!isset($this->aRules[$sRule])) {

src/Value/CSSFunction.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@ public function __toString()
8888
}
8989

9090
/**
91+
* @param OutputFormat $oOutputFormat
92+
*
9193
* @return string
9294
*/
93-
public function render(OutputFormat $oOutputFormat)
95+
public function render($oOutputFormat)
9496
{
9597
$aArguments = parent::render($oOutputFormat);
9698
return "{$this->sName}({$aArguments})";

src/Value/CSSString.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,11 @@ public function __toString()
9999
}
100100

101101
/**
102+
* @param OutputFormat $oOutputFormat
103+
*
102104
* @return string
103105
*/
104-
public function render(OutputFormat $oOutputFormat)
106+
public function render($oOutputFormat)
105107
{
106108
$sString = addslashes($this->sString);
107109
$sString = str_replace("\n", '\A', $sString);

src/Value/CalcRuleValueList.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ public function __construct($iLineNo = 0)
1515
}
1616

1717
/**
18+
* @param OutputFormat $oOutputFormat
19+
*
1820
* @return string
1921
*/
20-
public function render(OutputFormat $oOutputFormat)
22+
public function render($oOutputFormat)
2123
{
2224
return $oOutputFormat->implode(' ', $this->aComponents);
2325
}

src/Value/Color.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,11 @@ public function __toString()
160160
}
161161

162162
/**
163+
* @param OutputFormat $oOutputFormat
164+
*
163165
* @return string
164166
*/
165-
public function render(OutputFormat $oOutputFormat)
167+
public function render($oOutputFormat)
166168
{
167169
// Shorthand RGB color values
168170
if ($oOutputFormat->getRGBHashNotation() && implode('', array_keys($this->aComponents)) === 'rgb') {

src/Value/LineName.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,11 @@ public function __toString()
5656
}
5757

5858
/**
59+
* @param OutputFormat $oOutputFormat
60+
*
5961
* @return string
6062
*/
61-
public function render(OutputFormat $oOutputFormat)
63+
public function render($oOutputFormat)
6264
{
6365
return '[' . parent::render(OutputFormat::createCompact()) . ']';
6466
}

src/Value/Size.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,11 @@ public function __toString()
216216
}
217217

218218
/**
219+
* @param OutputFormat $oOutputFormat
220+
*
219221
* @return string
220222
*/
221-
public function render(OutputFormat $oOutputFormat)
223+
public function render($oOutputFormat)
222224
{
223225
$l = localeconv();
224226
$sPoint = preg_quote($l['decimal_point'], '/');

src/Value/URL.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ public function __toString()
8686
}
8787

8888
/**
89+
* @param OutputFormat $oOutputFormat
90+
*
8991
* @return string
9092
*/
91-
public function render(OutputFormat $oOutputFormat)
93+
public function render($oOutputFormat)
9294
{
9395
return "url({$this->oURL->render($oOutputFormat)})";
9496
}

src/Value/ValueList.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,11 @@ public function __toString()
9393
}
9494

9595
/**
96+
* @param OutputFormat $oOutputFormat
97+
*
9698
* @return string
9799
*/
98-
public function render(OutputFormat $oOutputFormat)
100+
public function render($oOutputFormat)
99101
{
100102
return $oOutputFormat->implode(
101103
$oOutputFormat->spaceBeforeListArgumentSeparator($this->sSeparator) . $this->sSeparator

0 commit comments

Comments
 (0)