From 20621268f1900b67134a7735ce2740e83736ff3b Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Fri, 25 Oct 2024 20:26:07 +0200 Subject: [PATCH] [BUGFIX] Avoid implicit nullable parameters This avoids deprecation warnings in PHP 8.4. Unfortunately, we need to remove the native type declaration for this to keep supporting PHP down to version 5.6. --- CHANGELOG.md | 2 +- src/CSSList/AtRuleBlockList.php | 4 +++- src/CSSList/Document.php | 2 +- src/CSSList/KeyFrame.php | 4 +++- src/Comment/Comment.php | 4 +++- src/Parser.php | 2 +- src/Property/CSSNamespace.php | 4 +++- src/Property/Charset.php | 4 +++- src/Property/Import.php | 4 +++- src/Renderable.php | 4 +++- src/Rule/Rule.php | 4 +++- src/RuleSet/AtRuleSet.php | 4 +++- src/RuleSet/DeclarationBlock.php | 4 +++- src/Value/CSSFunction.php | 4 +++- src/Value/CSSString.php | 4 +++- src/Value/CalcRuleValueList.php | 4 +++- src/Value/Color.php | 4 +++- src/Value/LineName.php | 4 +++- src/Value/Size.php | 4 +++- src/Value/URL.php | 4 +++- src/Value/ValueList.php | 4 +++- 21 files changed, 57 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1428bf75..dfe4b918 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,7 +7,7 @@ This project adheres to [Semantic Versioning](https://semver.org/). ### Added -- Add support for PHP 8.4 (#675, #701) +- Add support for PHP 8.4 (#675, #701, #746) ### Changed diff --git a/src/CSSList/AtRuleBlockList.php b/src/CSSList/AtRuleBlockList.php index 598fefc1..5930b932 100644 --- a/src/CSSList/AtRuleBlockList.php +++ b/src/CSSList/AtRuleBlockList.php @@ -57,9 +57,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { $sResult = $oOutputFormat->comments($this); $sResult .= $oOutputFormat->sBeforeAtRuleBlock; diff --git a/src/CSSList/Document.php b/src/CSSList/Document.php index bc5214db..7d9c6ec0 100644 --- a/src/CSSList/Document.php +++ b/src/CSSList/Document.php @@ -159,7 +159,7 @@ public function createShorthands() * * @return string */ - public function render(OutputFormat $oOutputFormat = null) + public function render($oOutputFormat = null) { if ($oOutputFormat === null) { $oOutputFormat = new OutputFormat(); diff --git a/src/CSSList/KeyFrame.php b/src/CSSList/KeyFrame.php index caef7b3d..69e2e4d9 100644 --- a/src/CSSList/KeyFrame.php +++ b/src/CSSList/KeyFrame.php @@ -68,9 +68,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { $sResult = $oOutputFormat->comments($this); $sResult .= "@{$this->vendorKeyFrame} {$this->animationName}{$oOutputFormat->spaceBeforeOpeningBrace()}{"; diff --git a/src/Comment/Comment.php b/src/Comment/Comment.php index 6128d749..e6ffaaf7 100644 --- a/src/Comment/Comment.php +++ b/src/Comment/Comment.php @@ -62,9 +62,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { return '/*' . $this->sComment . '*/'; } diff --git a/src/Parser.php b/src/Parser.php index beada56e..f60fc086 100644 --- a/src/Parser.php +++ b/src/Parser.php @@ -21,7 +21,7 @@ class Parser * @param Settings|null $oParserSettings * @param int $iLineNo the line number (starting from 1, not from 0) */ - public function __construct($sText, Settings $oParserSettings = null, $iLineNo = 1) + public function __construct($sText, $oParserSettings = null, $iLineNo = 1) { if ($oParserSettings === null) { $oParserSettings = Settings::create(); diff --git a/src/Property/CSSNamespace.php b/src/Property/CSSNamespace.php index 0d7eb496..d1bac4f7 100644 --- a/src/Property/CSSNamespace.php +++ b/src/Property/CSSNamespace.php @@ -60,9 +60,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { return '@namespace ' . ($this->sPrefix === null ? '' : $this->sPrefix . ' ') . $this->mUrl->render($oOutputFormat) . ';'; diff --git a/src/Property/Charset.php b/src/Property/Charset.php index 26e1b250..870380e3 100644 --- a/src/Property/Charset.php +++ b/src/Property/Charset.php @@ -78,9 +78,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { return "{$oOutputFormat->comments($this)}@charset {$this->oCharset->render($oOutputFormat)};"; } diff --git a/src/Property/Import.php b/src/Property/Import.php index d715a7a0..2a7cad54 100644 --- a/src/Property/Import.php +++ b/src/Property/Import.php @@ -79,9 +79,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { return $oOutputFormat->comments($this) . "@import " . $this->oLocation->render($oOutputFormat) . ($this->sMediaQuery === null ? '' : ' ' . $this->sMediaQuery) . ';'; diff --git a/src/Renderable.php b/src/Renderable.php index dc1bff3c..d7c6aba6 100644 --- a/src/Renderable.php +++ b/src/Renderable.php @@ -10,9 +10,11 @@ interface Renderable public function __toString(); /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat); + public function render($oOutputFormat); /** * @return int diff --git a/src/Rule/Rule.php b/src/Rule/Rule.php index 80f2490f..c1bad65e 100644 --- a/src/Rule/Rule.php +++ b/src/Rule/Rule.php @@ -344,9 +344,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { $sResult = "{$oOutputFormat->comments($this)}{$this->sRule}:{$oOutputFormat->spaceAfterRuleName()}"; if ($this->mValue instanceof Value) { // Can also be a ValueList diff --git a/src/RuleSet/AtRuleSet.php b/src/RuleSet/AtRuleSet.php index aab6d799..93fd07af 100644 --- a/src/RuleSet/AtRuleSet.php +++ b/src/RuleSet/AtRuleSet.php @@ -60,9 +60,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { $sResult = $oOutputFormat->comments($this); $sArgs = $this->sArgs; diff --git a/src/RuleSet/DeclarationBlock.php b/src/RuleSet/DeclarationBlock.php index 46578fcf..8a1da14e 100644 --- a/src/RuleSet/DeclarationBlock.php +++ b/src/RuleSet/DeclarationBlock.php @@ -836,11 +836,13 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string * * @throws OutputException */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { $sResult = $oOutputFormat->comments($this); if (count($this->aSelectors) === 0) { diff --git a/src/Value/CSSFunction.php b/src/Value/CSSFunction.php index 300dc3ec..82ffc48c 100644 --- a/src/Value/CSSFunction.php +++ b/src/Value/CSSFunction.php @@ -88,9 +88,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { $aArguments = parent::render($oOutputFormat); return "{$this->sName}({$aArguments})"; diff --git a/src/Value/CSSString.php b/src/Value/CSSString.php index da498d41..c19b238f 100644 --- a/src/Value/CSSString.php +++ b/src/Value/CSSString.php @@ -99,9 +99,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { $sString = addslashes($this->sString); $sString = str_replace("\n", '\A', $sString); diff --git a/src/Value/CalcRuleValueList.php b/src/Value/CalcRuleValueList.php index 7dbd26a1..17fbe7cf 100644 --- a/src/Value/CalcRuleValueList.php +++ b/src/Value/CalcRuleValueList.php @@ -15,9 +15,11 @@ public function __construct($iLineNo = 0) } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { return $oOutputFormat->implode(' ', $this->aComponents); } diff --git a/src/Value/Color.php b/src/Value/Color.php index 5daad412..a002760b 100644 --- a/src/Value/Color.php +++ b/src/Value/Color.php @@ -160,9 +160,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { // Shorthand RGB color values if ($oOutputFormat->getRGBHashNotation() && implode('', array_keys($this->aComponents)) === 'rgb') { diff --git a/src/Value/LineName.php b/src/Value/LineName.php index e231ce38..588cb4cb 100644 --- a/src/Value/LineName.php +++ b/src/Value/LineName.php @@ -56,9 +56,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { return '[' . parent::render(OutputFormat::createCompact()) . ']'; } diff --git a/src/Value/Size.php b/src/Value/Size.php index 648c9a60..af8b3a3b 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -216,9 +216,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { $l = localeconv(); $sPoint = preg_quote($l['decimal_point'], '/'); diff --git a/src/Value/URL.php b/src/Value/URL.php index cdb911c3..92da9726 100644 --- a/src/Value/URL.php +++ b/src/Value/URL.php @@ -86,9 +86,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { return "url({$this->oURL->render($oOutputFormat)})"; } diff --git a/src/Value/ValueList.php b/src/Value/ValueList.php index a93acc7b..80b26f97 100644 --- a/src/Value/ValueList.php +++ b/src/Value/ValueList.php @@ -93,9 +93,11 @@ public function __toString() } /** + * @param OutputFormat|null $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { return $oOutputFormat->implode( $oOutputFormat->spaceBeforeListArgumentSeparator($this->sSeparator) . $this->sSeparator