Skip to content

Commit

Permalink
[CLEANUP] Rector: Change return type based on strict scalar returns -…
Browse files Browse the repository at this point in the history
… string, int, float or bool (MyIntervals#589)

This applies the rule ReturnTypeFromStrictScalarReturnExprRector. For
Details see:
https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#returntypefromstrictscalarreturnexprrector

Signed-off-by: Daniel Ziegenberg <[email protected]>
  • Loading branch information
ziegenberg authored Jun 19, 2024
1 parent 4a9b2f5 commit e299f80
Show file tree
Hide file tree
Showing 17 changed files with 24 additions and 78 deletions.
5 changes: 1 addition & 4 deletions src/CSSList/AtRuleBlockList.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
$sResult = $oOutputFormat->comments($this);
$sResult .= $oOutputFormat->sBeforeAtRuleBlock;
Expand Down
4 changes: 1 addition & 3 deletions src/CSSList/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,8 @@ public function createShorthands()
* Overrides `render()` to make format argument optional.
*
* @param OutputFormat|null $oOutputFormat
*
* @return string
*/
public function render(OutputFormat $oOutputFormat = null)
public function render(OutputFormat $oOutputFormat = null): string
{
if ($oOutputFormat === null) {
$oOutputFormat = new OutputFormat();
Expand Down
5 changes: 1 addition & 4 deletions src/CSSList/KeyFrame.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,7 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
$sResult = $oOutputFormat->comments($this);
$sResult .= "@{$this->vendorKeyFrame} {$this->animationName}{$oOutputFormat->spaceBeforeOpeningBrace()}{";
Expand Down
5 changes: 1 addition & 4 deletions src/Comment/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,7 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
return '/*' . $this->sComment . '*/';
}
Expand Down
8 changes: 3 additions & 5 deletions src/OutputFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,8 @@ public function safely($cCode)
* @param string $sSeparator
* @param array<array-key, Renderable|string> $aValues
* @param bool $bIncreaseLevel
*
* @return string
*/
public function implode($sSeparator, array $aValues, $bIncreaseLevel = false)
public function implode($sSeparator, array $aValues, $bIncreaseLevel = false): string
{
$sResult = '';
$oFormat = $this->oFormat;
Expand Down Expand Up @@ -218,7 +216,7 @@ public function removeLastSemicolon($sString)
*
* @return string
*/
public function comments(Commentable $oCommentable)
public function comments(Commentable $oCommentable): string
{
if (!$this->oFormat->bRenderComments) {
return '';
Expand Down Expand Up @@ -248,7 +246,7 @@ private function prepareSpace($sSpaceString)
/**
* @return string
*/
private function indent()
private function indent(): string
{
return str_repeat($this->oFormat->sIndentation, $this->oFormat->level());
}
Expand Down
8 changes: 2 additions & 6 deletions src/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -457,10 +457,8 @@ public function strlen($sString): int
/**
* @param int $iStart
* @param int $iLength
*
* @return string
*/
private function substr($iStart, $iLength)
private function substr($iStart, $iLength): string
{
if ($iLength < 0) {
$iLength = $this->iLength - $iStart + $iLength;
Expand All @@ -479,10 +477,8 @@ private function substr($iStart, $iLength)

/**
* @param string $sString
*
* @return string
*/
private function strtolower($sString)
private function strtolower($sString): string
{
if ($this->oParserSettings->bMultibyteSupport) {
return mb_strtolower($sString, $this->sCharset);
Expand Down
7 changes: 2 additions & 5 deletions src/Property/CSSNamespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
return '@namespace ' . ($this->sPrefix === null ? '' : $this->sPrefix . ' ')
. $this->mUrl->render($oOutputFormat) . ';';
Expand Down Expand Up @@ -107,7 +104,7 @@ public function setPrefix($sPrefix)
/**
* @return string
*/
public function atRuleName()
public function atRuleName(): string
{
return 'namespace';
}
Expand Down
10 changes: 2 additions & 8 deletions src/Property/Charset.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,12 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
return "{$oOutputFormat->comments($this)}@charset {$this->oCharset->render($oOutputFormat)};";
}

/**
* @return string
*/
public function atRuleName()
public function atRuleName(): string
{
return 'charset';
}
Expand Down
10 changes: 2 additions & 8 deletions src/Property/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,19 +78,13 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
return $oOutputFormat->comments($this) . "@import " . $this->oLocation->render($oOutputFormat)
. ($this->sMediaQuery === null ? '' : ' ' . $this->sMediaQuery) . ';';
}

/**
* @return string
*/
public function atRuleName()
public function atRuleName(): string
{
return 'import';
}
Expand Down
5 changes: 1 addition & 4 deletions src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,7 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
$sResult = "{$oOutputFormat->comments($this)}{$this->sRule}:{$oOutputFormat->spaceAfterRuleName()}";
if ($this->mValue instanceof Value) { // Can also be a ValueList
Expand Down
5 changes: 1 addition & 4 deletions src/RuleSet/AtRuleSet.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,7 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
$sResult = $oOutputFormat->comments($this);
$sArgs = $this->sArgs;
Expand Down
4 changes: 1 addition & 3 deletions src/RuleSet/DeclarationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -799,11 +799,9 @@ public function __toString()
}

/**
* @return string
*
* @throws OutputException
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
$sResult = $oOutputFormat->comments($this);
if (count($this->aSelectors) === 0) {
Expand Down
5 changes: 1 addition & 4 deletions src/Value/CSSString.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,7 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
$sString = addslashes($this->sString);
$sString = str_replace("\n", '\A', $sString);
Expand Down
5 changes: 1 addition & 4 deletions src/Value/LineName.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,7 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
return '[' . parent::render(OutputFormat::createCompact()) . ']';
}
Expand Down
7 changes: 2 additions & 5 deletions src/Value/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function isColorComponent()
*
* @return false if the unit an angle, a duration, a frequency or the number is a component in a Color object.
*/
public function isSize()
public function isSize(): bool
{
if (in_array($this->sUnit, self::NON_SIZE_UNITS, true)) {
return false;
Expand All @@ -206,10 +206,7 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
$l = localeconv();
$sPoint = preg_quote($l['decimal_point'], '/');
Expand Down
5 changes: 1 addition & 4 deletions src/Value/URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,7 @@ public function __toString()
return $this->render(new OutputFormat());
}

/**
* @return string
*/
public function render(OutputFormat $oOutputFormat)
public function render(OutputFormat $oOutputFormat): string
{
return "url({$this->oURL->render($oOutputFormat)})";
}
Expand Down
4 changes: 1 addition & 3 deletions src/Value/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,10 @@ private static function parseMicrosoftFilter(ParserState $oParserState)
}

/**
* @return string
*
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*/
private static function parseUnicodeRangeValue(ParserState $oParserState)
private static function parseUnicodeRangeValue(ParserState $oParserState): string
{
$iCodepointMaxLength = 6; // Code points outside BMP can use up to six digits
$sRange = "";
Expand Down

0 comments on commit e299f80

Please sign in to comment.