Skip to content

Commit

Permalink
[BUGFIX] Avoid implicit nullable parameters
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
oliverklee committed Oct 25, 2024
1 parent d2f38b4 commit 8a0afb7
Show file tree
Hide file tree
Showing 21 changed files with 58 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
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|null $oOutputFormat
*
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render($oOutputFormat)
{
$sResult = $oOutputFormat->comments($this);
$sResult .= $oOutputFormat->sBeforeAtRuleBlock;
Expand Down
2 changes: 1 addition & 1 deletion src/CSSList/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
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|null $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|null $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|null $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|null $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|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) . ';';
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|null $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 @@ -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
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|null $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 @@ -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) {
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|null $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|null $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|null $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|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') {
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|null $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|null $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|null $oOutputFormat
*
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render($oOutputFormat)
{
return "url({$this->oURL->render($oOutputFormat)})";
}
Expand Down
5 changes: 4 additions & 1 deletion src/Value/ValueList.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ abstract class ValueList extends Value

/**
* phpcs:ignore Generic.Files.LineLength
*
* @param array<int, RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string>|RuleValueList|CSSFunction|CSSString|LineName|Size|URL|string $aComponents
* @param string $sSeparator
* @param int $iLineNo
Expand Down Expand Up @@ -93,9 +94,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
Expand Down

0 comments on commit 8a0afb7

Please sign in to comment.