From 66b8153c54b268a40eddf526084ed60e11ac48d3 Mon Sep 17 00:00:00 2001 From: Daniel Ziegenberg Date: Wed, 19 Jun 2024 19:17:45 +0200 Subject: [PATCH] [CLEANUP] Rector: Add return type from return direct array This applies the rule ReturnTypeFromReturnDirectArrayRector. For Details see: https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md#returntypefromreturndirectarrayrector Signed-off-by: Daniel Ziegenberg --- src/Parsing/ParserState.php | 13 +++---------- src/Rule/Rule.php | 2 +- tests/CSSList/DocumentTest.php | 2 +- tests/RuleSet/DeclarationBlockTest.php | 16 ++++++++-------- 4 files changed, 13 insertions(+), 20 deletions(-) diff --git a/src/Parsing/ParserState.php b/src/Parsing/ParserState.php index 3b80b795..e5f216a4 100644 --- a/src/Parsing/ParserState.php +++ b/src/Parsing/ParserState.php @@ -270,10 +270,8 @@ public function comes($sString, $bCaseInsensitive = false): bool /** * @param int $iLength * @param int $iOffset - * - * @return string */ - public function peek($iLength = 1, $iOffset = 0) + public function peek($iLength = 1, $iOffset = 0): string { $iOffset += $this->iCurrentPosition; if ($iOffset >= $this->iLength) { @@ -285,12 +283,10 @@ public function peek($iLength = 1, $iOffset = 0) /** * @param int $mValue * - * @return string - * * @throws UnexpectedEOFException * @throws UnexpectedTokenException */ - public function consume($mValue = 1) + public function consume($mValue = 1): string { if (is_string($mValue)) { $iLineCount = substr_count($mValue, "\n"); @@ -410,10 +406,7 @@ public function consumeUntil($aEnd, $bIncludeEnd = false, $consumeEnd = false, a ); } - /** - * @return string - */ - private function inputLeft() + private function inputLeft(): string { return $this->substr($this->iCurrentPosition, -1); } diff --git a/src/Rule/Rule.php b/src/Rule/Rule.php index f5efb77d..163fde0f 100644 --- a/src/Rule/Rule.php +++ b/src/Rule/Rule.php @@ -117,7 +117,7 @@ public static function parse(ParserState $oParserState) * * @return array */ - private static function listDelimiterForRule($sRule) + private static function listDelimiterForRule($sRule): array { if (preg_match('/^font($|-)/', $sRule)) { return [',', '/', ' ']; diff --git a/tests/CSSList/DocumentTest.php b/tests/CSSList/DocumentTest.php index 177caa33..10f72e3e 100644 --- a/tests/CSSList/DocumentTest.php +++ b/tests/CSSList/DocumentTest.php @@ -50,7 +50,7 @@ public function getContentsInitiallyReturnsEmptyArray(): void /** * @return array>> */ - public static function contentsDataProvider() + public static function contentsDataProvider(): array { return [ 'empty array' => [[]], diff --git a/tests/RuleSet/DeclarationBlockTest.php b/tests/RuleSet/DeclarationBlockTest.php index ca10d229..a32f53ba 100644 --- a/tests/RuleSet/DeclarationBlockTest.php +++ b/tests/RuleSet/DeclarationBlockTest.php @@ -33,7 +33,7 @@ public function expandBorderShorthand($sCss, $sExpected): void /** * @return array> */ - public static function expandBorderShorthandProvider() + public static function expandBorderShorthandProvider(): array { return [ ['body{ border: 2px solid #000 }', 'body {border-width: 2px;border-style: solid;border-color: #000;}'], @@ -66,7 +66,7 @@ public function expandFontShorthand($sCss, $sExpected): void /** * @return array> */ - public static function expandFontShorthandProvider() + public static function expandFontShorthandProvider(): array { return [ [ @@ -122,7 +122,7 @@ public function expandBackgroundShorthand($sCss, $sExpected): void /** * @return array> */ - public static function expandBackgroundShorthandProvider() + public static function expandBackgroundShorthandProvider(): array { return [ ['body {border: 1px;}', 'body {border: 1px;}'], @@ -175,7 +175,7 @@ public function expandDimensionsShorthand($sCss, $sExpected): void /** * @return array> */ - public static function expandDimensionsShorthandProvider() + public static function expandDimensionsShorthandProvider(): array { return [ ['body {border: 1px;}', 'body {border: 1px;}'], @@ -213,7 +213,7 @@ public function createBorderShorthand($sCss, $sExpected): void /** * @return array> */ - public static function createBorderShorthandProvider() + public static function createBorderShorthandProvider(): array { return [ ['body {border-width: 2px;border-style: solid;border-color: #000;}', 'body {border: 2px solid #000;}'], @@ -244,7 +244,7 @@ public function createFontShorthand($sCss, $sExpected): void /** * @return array> */ - public static function createFontShorthandProvider() + public static function createFontShorthandProvider(): array { return [ ['body {font-size: 12px; font-family: serif}', 'body {font: 12px serif;}'], @@ -287,7 +287,7 @@ public function createDimensionsShorthand($sCss, $sExpected): void /** * @return array> */ - public static function createDimensionsShorthandProvider() + public static function createDimensionsShorthandProvider(): array { return [ ['body {border: 1px;}', 'body {border: 1px;}'], @@ -325,7 +325,7 @@ public function createBackgroundShorthand($sCss, $sExpected): void /** * @return array> */ - public static function createBackgroundShorthandProvider() + public static function createBackgroundShorthandProvider(): array { return [ ['body {border: 1px;}', 'body {border: 1px;}'],