From f65d376a1b5f65358f94734c4f1ed7cff3ec042f Mon Sep 17 00:00:00 2001 From: Oliver Klee Date: Thu, 4 Jul 2024 11:37:12 +0200 Subject: [PATCH] [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 --- src/CSSList/AtRuleBlockList.php | 4 +++- src/CSSList/CSSList.php | 4 ++-- src/CSSList/Document.php | 4 ++-- 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/RuleSet/RuleSet.php | 2 +- 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 +++- 22 files changed, 60 insertions(+), 24 deletions(-) diff --git a/src/CSSList/AtRuleBlockList.php b/src/CSSList/AtRuleBlockList.php index 598fefc1..47413d2d 100644 --- a/src/CSSList/AtRuleBlockList.php +++ b/src/CSSList/AtRuleBlockList.php @@ -57,9 +57,11 @@ public function __toString() } /** + * @param OutputFormat $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { $sResult = $oOutputFormat->comments($this); $sResult .= $oOutputFormat->sBeforeAtRuleBlock; diff --git a/src/CSSList/CSSList.php b/src/CSSList/CSSList.php index 4bb37589..b6e21cd9 100644 --- a/src/CSSList/CSSList.php +++ b/src/CSSList/CSSList.php @@ -286,8 +286,8 @@ public function append($oItem) * Splices the list of contents. * * @param int $iOffset - * @param int $iLength - * @param array $mReplacement + * @param int|null $iLength + * @param array|null $mReplacement * * @return void */ diff --git a/src/CSSList/Document.php b/src/CSSList/Document.php index bad99831..acad2319 100644 --- a/src/CSSList/Document.php +++ b/src/CSSList/Document.php @@ -78,7 +78,7 @@ public function getAllRuleSets() /** * Returns all `Value` objects found recursively in `Rule`s in the tree. * - * @param CSSList|RuleSet|string $mElement + * @param CSSList|RuleSet|string|null $mElement * the `CSSList` or `RuleSet` to start the search from (defaults to the whole document). * If a string is given, it is used as rule name filter. * @param bool $bSearchInFunctionArguments whether to also return Value objects used as Function arguments. @@ -155,7 +155,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..e691fc73 100644 --- a/src/CSSList/KeyFrame.php +++ b/src/CSSList/KeyFrame.php @@ -68,9 +68,11 @@ public function __toString() } /** + * @param OutputFormat $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..4319ce18 100644 --- a/src/Comment/Comment.php +++ b/src/Comment/Comment.php @@ -62,9 +62,11 @@ public function __toString() } /** + * @param OutputFormat $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 e582cfab..ecf73e61 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..407e6692 100644 --- a/src/Property/CSSNamespace.php +++ b/src/Property/CSSNamespace.php @@ -60,9 +60,11 @@ public function __toString() } /** + * @param OutputFormat $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..94be56f1 100644 --- a/src/Property/Charset.php +++ b/src/Property/Charset.php @@ -78,9 +78,11 @@ public function __toString() } /** + * @param OutputFormat $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..efbe3278 100644 --- a/src/Property/Import.php +++ b/src/Property/Import.php @@ -79,9 +79,11 @@ public function __toString() } /** + * @param OutputFormat $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..415e4ba5 100644 --- a/src/Renderable.php +++ b/src/Renderable.php @@ -10,9 +10,11 @@ interface Renderable public function __toString(); /** + * @param OutputFormat $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 9b693ece..394bdc08 100644 --- a/src/Rule/Rule.php +++ b/src/Rule/Rule.php @@ -348,9 +348,11 @@ public function __toString() } /** + * @param OutputFormat $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..c0c93855 100644 --- a/src/RuleSet/AtRuleSet.php +++ b/src/RuleSet/AtRuleSet.php @@ -60,9 +60,11 @@ public function __toString() } /** + * @param OutputFormat $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 b218bd8c..37836d40 100644 --- a/src/RuleSet/DeclarationBlock.php +++ b/src/RuleSet/DeclarationBlock.php @@ -810,11 +810,13 @@ public function __toString() } /** + * @param OutputFormat $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/RuleSet/RuleSet.php b/src/RuleSet/RuleSet.php index adb9be92..8cbbd34f 100644 --- a/src/RuleSet/RuleSet.php +++ b/src/RuleSet/RuleSet.php @@ -102,7 +102,7 @@ public function getLineNo() * * @return void */ - public function addRule(Rule $oRule, Rule $oSibling = null) + public function addRule(Rule $oRule, $oSibling = null) { $sRule = $oRule->getRule(); if (!isset($this->aRules[$sRule])) { diff --git a/src/Value/CSSFunction.php b/src/Value/CSSFunction.php index 300dc3ec..68909523 100644 --- a/src/Value/CSSFunction.php +++ b/src/Value/CSSFunction.php @@ -88,9 +88,11 @@ public function __toString() } /** + * @param OutputFormat $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..f1ffc8c1 100644 --- a/src/Value/CSSString.php +++ b/src/Value/CSSString.php @@ -99,9 +99,11 @@ public function __toString() } /** + * @param OutputFormat $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..786be482 100644 --- a/src/Value/CalcRuleValueList.php +++ b/src/Value/CalcRuleValueList.php @@ -15,9 +15,11 @@ public function __construct($iLineNo = 0) } /** + * @param OutputFormat $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..1ad50151 100644 --- a/src/Value/Color.php +++ b/src/Value/Color.php @@ -160,9 +160,11 @@ public function __toString() } /** + * @param OutputFormat $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..4a3bf524 100644 --- a/src/Value/LineName.php +++ b/src/Value/LineName.php @@ -56,9 +56,11 @@ public function __toString() } /** + * @param OutputFormat $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..54e6aed4 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -216,9 +216,11 @@ public function __toString() } /** + * @param OutputFormat $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..f4f23df1 100644 --- a/src/Value/URL.php +++ b/src/Value/URL.php @@ -86,9 +86,11 @@ public function __toString() } /** + * @param OutputFormat $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..6f4c37ca 100644 --- a/src/Value/ValueList.php +++ b/src/Value/ValueList.php @@ -93,9 +93,11 @@ public function __toString() } /** + * @param OutputFormat $oOutputFormat + * * @return string */ - public function render(OutputFormat $oOutputFormat) + public function render($oOutputFormat) { return $oOutputFormat->implode( $oOutputFormat->spaceBeforeListArgumentSeparator($this->sSeparator) . $this->sSeparator