Skip to content

[BUGFIX] Ensure PHP 8.4 compatibility for nullable parameters #677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/CSSList/AtRuleBlockList.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,11 @@ public function __toString()
}

/**
* @param OutputFormat $oOutputFormat
*
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render($oOutputFormat)
Comment on lines +60 to +64
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't look right. It seems to be reverting a previous change.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it's removing the type declaration.

The reason for this that there are two possible ways to fix the implicit nullable parameters:

  1. make the parameters explicitly nullable using a native type declaration (which is not possible with PHP 5.6, which we support in this branch)
  2. drop the native type declaration for this parameter and use PHPDoc type annotations instead

I'll create a separate pre-PR to do 2. first (without changing the type).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is another way, which is to make a 9.0 release with where we're at. The only breaking change I'm aware of is requiring PHP >= 7.2.

{
$sResult = $oOutputFormat->comments($this);
$sResult .= $oOutputFormat->sBeforeAtRuleBlock;
Expand Down
4 changes: 2 additions & 2 deletions src/CSSList/CSSList.php
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,8 @@ public function append($oItem)
* Splices the list of contents.
*
* @param int $iOffset
* @param int $iLength
* @param array<int, RuleSet|CSSList|Import|Charset> $mReplacement
* @param int|null $iLength
* @param array<int, RuleSet|CSSList|Import|Charset>|null $mReplacement
*
* @return void
*/
Expand Down
4 changes: 2 additions & 2 deletions src/CSSList/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion src/CSSList/KeyFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()}{";
Expand Down
4 changes: 3 additions & 1 deletion src/Comment/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,11 @@ public function __toString()
}

/**
* @param OutputFormat $oOutputFormat
*
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render($oOutputFormat)
{
return '/*' . $this->sComment . '*/';
}
Expand Down
2 changes: 1 addition & 1 deletion src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 3 additions & 1 deletion src/Property/CSSNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) . ';';
Expand Down
4 changes: 3 additions & 1 deletion src/Property/Charset.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)};";
}
Expand Down
4 changes: 3 additions & 1 deletion src/Property/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) . ';';
Expand Down
4 changes: 3 additions & 1 deletion src/Renderable.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion src/RuleSet/AtRuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/RuleSet/DeclarationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/RuleSet/RuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -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])) {
Expand Down
4 changes: 3 additions & 1 deletion src/Value/CSSFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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})";
Expand Down
4 changes: 3 additions & 1 deletion src/Value/CSSString.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 3 additions & 1 deletion src/Value/CalcRuleValueList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
4 changes: 3 additions & 1 deletion src/Value/Color.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
4 changes: 3 additions & 1 deletion src/Value/LineName.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()) . ']';
}
Expand Down
4 changes: 3 additions & 1 deletion src/Value/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'], '/');
Expand Down
4 changes: 3 additions & 1 deletion src/Value/URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)})";
}
Expand Down
4 changes: 3 additions & 1 deletion src/Value/ValueList.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down