From e299f800054802f48ab6f374c2916bb28dd3b3f2 Mon Sep 17 00:00:00 2001 From: Daniel Ziegenberg Date: Wed, 19 Jun 2024 14:42:22 +0200 Subject: [PATCH] [CLEANUP] Rector: Change return type based on strict scalar returns - string, int, float or bool (#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 --- src/CSSList/AtRuleBlockList.php | 5 +---- src/CSSList/Document.php | 4 +--- src/CSSList/KeyFrame.php | 5 +---- src/Comment/Comment.php | 5 +---- src/OutputFormatter.php | 8 +++----- src/Parsing/ParserState.php | 8 ++------ src/Property/CSSNamespace.php | 7 ++----- src/Property/Charset.php | 10 ++-------- src/Property/Import.php | 10 ++-------- src/Rule/Rule.php | 5 +---- src/RuleSet/AtRuleSet.php | 5 +---- src/RuleSet/DeclarationBlock.php | 4 +--- src/Value/CSSString.php | 5 +---- src/Value/LineName.php | 5 +---- src/Value/Size.php | 7 ++----- src/Value/URL.php | 5 +---- src/Value/Value.php | 4 +--- 17 files changed, 24 insertions(+), 78 deletions(-) diff --git a/src/CSSList/AtRuleBlockList.php b/src/CSSList/AtRuleBlockList.php index 006ff5cc..eb921ed8 100644 --- a/src/CSSList/AtRuleBlockList.php +++ b/src/CSSList/AtRuleBlockList.php @@ -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; diff --git a/src/CSSList/Document.php b/src/CSSList/Document.php index afdba9ac..145d0617 100644 --- a/src/CSSList/Document.php +++ b/src/CSSList/Document.php @@ -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(); diff --git a/src/CSSList/KeyFrame.php b/src/CSSList/KeyFrame.php index 0c5658af..fafba1dd 100644 --- a/src/CSSList/KeyFrame.php +++ b/src/CSSList/KeyFrame.php @@ -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()}{"; diff --git a/src/Comment/Comment.php b/src/Comment/Comment.php index 6128d749..59187bf1 100644 --- a/src/Comment/Comment.php +++ b/src/Comment/Comment.php @@ -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 . '*/'; } diff --git a/src/OutputFormatter.php b/src/OutputFormatter.php index 501d15da..ae73ffeb 100644 --- a/src/OutputFormatter.php +++ b/src/OutputFormatter.php @@ -166,10 +166,8 @@ public function safely($cCode) * @param string $sSeparator * @param array $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; @@ -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 ''; @@ -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()); } diff --git a/src/Parsing/ParserState.php b/src/Parsing/ParserState.php index 39e08a5f..3b80b795 100644 --- a/src/Parsing/ParserState.php +++ b/src/Parsing/ParserState.php @@ -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; @@ -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); diff --git a/src/Property/CSSNamespace.php b/src/Property/CSSNamespace.php index ad87a7d8..8ed2c3ce 100644 --- a/src/Property/CSSNamespace.php +++ b/src/Property/CSSNamespace.php @@ -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) . ';'; @@ -107,7 +104,7 @@ public function setPrefix($sPrefix) /** * @return string */ - public function atRuleName() + public function atRuleName(): string { return 'namespace'; } diff --git a/src/Property/Charset.php b/src/Property/Charset.php index 26e1b250..47778932 100644 --- a/src/Property/Charset.php +++ b/src/Property/Charset.php @@ -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'; } diff --git a/src/Property/Import.php b/src/Property/Import.php index f956afb4..021fa211 100644 --- a/src/Property/Import.php +++ b/src/Property/Import.php @@ -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'; } diff --git a/src/Rule/Rule.php b/src/Rule/Rule.php index 37ed89d3..f5efb77d 100644 --- a/src/Rule/Rule.php +++ b/src/Rule/Rule.php @@ -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 diff --git a/src/RuleSet/AtRuleSet.php b/src/RuleSet/AtRuleSet.php index aab6d799..1da45fb7 100644 --- a/src/RuleSet/AtRuleSet.php +++ b/src/RuleSet/AtRuleSet.php @@ -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; diff --git a/src/RuleSet/DeclarationBlock.php b/src/RuleSet/DeclarationBlock.php index a6aceefa..95ccd134 100644 --- a/src/RuleSet/DeclarationBlock.php +++ b/src/RuleSet/DeclarationBlock.php @@ -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) { diff --git a/src/Value/CSSString.php b/src/Value/CSSString.php index da498d41..8988d5e6 100644 --- a/src/Value/CSSString.php +++ b/src/Value/CSSString.php @@ -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); diff --git a/src/Value/LineName.php b/src/Value/LineName.php index 6eaf7620..c8c1e33a 100644 --- a/src/Value/LineName.php +++ b/src/Value/LineName.php @@ -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()) . ']'; } diff --git a/src/Value/Size.php b/src/Value/Size.php index 0bc11666..b8321fd8 100644 --- a/src/Value/Size.php +++ b/src/Value/Size.php @@ -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; @@ -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'], '/'); diff --git a/src/Value/URL.php b/src/Value/URL.php index cdb911c3..f0196c75 100644 --- a/src/Value/URL.php +++ b/src/Value/URL.php @@ -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)})"; } diff --git a/src/Value/Value.php b/src/Value/Value.php index 5b52a22d..3aad2041 100644 --- a/src/Value/Value.php +++ b/src/Value/Value.php @@ -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 = "";