Skip to content

Commit

Permalink
[CLEANUP] Rector: Add return type to function like with return new (M…
Browse files Browse the repository at this point in the history
…yIntervals#591)

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

Signed-off-by: Daniel Ziegenberg <[email protected]>
  • Loading branch information
ziegenberg authored Jun 19, 2024
1 parent 9fe826f commit 1b4dc29
Show file tree
Hide file tree
Showing 11 changed files with 14 additions and 32 deletions.
4 changes: 1 addition & 3 deletions src/CSSList/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ public function __construct($iLineNo = 0)
}

/**
* @return Document
*
* @throws SourceException
*/
public static function parse(ParserState $oParserState)
public static function parse(ParserState $oParserState): Document
{
$oDocument = new Document($oParserState->currentLine());
CSSList::parseList($oParserState, $oDocument);
Expand Down
4 changes: 1 addition & 3 deletions src/OutputFormat.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,10 +303,8 @@ public function level()

/**
* Creates an instance of this class without any particular formatting settings.
*
* @return self
*/
public static function create()
public static function create(): OutputFormat
{
return new OutputFormat();
}
Expand Down
7 changes: 3 additions & 4 deletions src/Parsing/ParserState.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Sabberworm\CSS\Parsing;

use Sabberworm\CSS\Comment\Comment;
use Sabberworm\CSS\Parsing\Anchor;
use Sabberworm\CSS\Settings;

class ParserState
Expand Down Expand Up @@ -114,10 +115,8 @@ public function getSettings()
return $this->oParserSettings;
}

/**
* @return \Sabberworm\CSS\Parsing\Anchor
*/
public function anchor()

public function anchor(): Anchor
{
return new Anchor($this->iCurrentPosition, $this);
}
Expand Down
4 changes: 1 addition & 3 deletions src/Rule/Rule.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,10 @@ public function __construct($sRule, $iLineNo = 0, $iColNo = 0)
}

/**
* @return Rule
*
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*/
public static function parse(ParserState $oParserState)
public static function parse(ParserState $oParserState): Rule
{
$aComments = $oParserState->consumeWhiteSpace();
$oRule = new Rule(
Expand Down
2 changes: 1 addition & 1 deletion src/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ private function __construct()
/**
* @return self new instance
*/
public static function create()
public static function create(): Settings
{
return new Settings();
}
Expand Down
4 changes: 1 addition & 3 deletions src/Value/CSSString.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,11 @@ public function __construct($sString, $iLineNo = 0)
}

/**
* @return CSSString
*
* @throws SourceException
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*/
public static function parse(ParserState $oParserState)
public static function parse(ParserState $oParserState): CSSString
{
$sBegin = $oParserState->peek();
$sQuote = null;
Expand Down
4 changes: 1 addition & 3 deletions src/Value/CalcFunction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,10 @@ class CalcFunction extends CSSFunction
* @param ParserState $oParserState
* @param bool $bIgnoreCase
*
* @return CalcFunction
*
* @throws UnexpectedTokenException
* @throws UnexpectedEOFException
*/
public static function parse(ParserState $oParserState, $bIgnoreCase = false)
public static function parse(ParserState $oParserState, $bIgnoreCase = false): CalcFunction
{
$aOperators = ['+', '-', '*', '/'];
$sFunction = $oParserState->parseIdentifier();
Expand Down
4 changes: 1 addition & 3 deletions src/Value/LineName.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@ public function __construct(array $aComponents = [], $iLineNo = 0)
}

/**
* @return LineName
*
* @throws UnexpectedTokenException
* @throws UnexpectedEOFException
*/
public static function parse(ParserState $oParserState)
public static function parse(ParserState $oParserState): LineName
{
$oParserState->consume('[');
$oParserState->consumeWhiteSpace();
Expand Down
4 changes: 1 addition & 3 deletions src/Value/Size.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,10 @@ public function __construct($fSize, $sUnit = null, $bIsColorComponent = false, $
/**
* @param bool $bIsColorComponent
*
* @return Size
*
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*/
public static function parse(ParserState $oParserState, $bIsColorComponent = false)
public static function parse(ParserState $oParserState, $bIsColorComponent = false): Size
{
$sSize = '';
if ($oParserState->comes('-')) {
Expand Down
4 changes: 1 addition & 3 deletions src/Value/URL.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@ public function __construct(CSSString $oURL, $iLineNo = 0)
}

/**
* @return URL
*
* @throws SourceException
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*/
public static function parse(ParserState $oParserState)
public static function parse(ParserState $oParserState): URL
{
$oAnchor = $oParserState->anchor();
$sIdentifier = '';
Expand Down
5 changes: 2 additions & 3 deletions src/Value/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Sabberworm\CSS\Parsing\SourceException;
use Sabberworm\CSS\Parsing\UnexpectedEOFException;
use Sabberworm\CSS\Parsing\UnexpectedTokenException;
use Sabberworm\CSS\Value\CSSFunction;
use Sabberworm\CSS\Renderable;

/**
Expand Down Expand Up @@ -170,12 +171,10 @@ public static function parsePrimitiveValue(ParserState $oParserState)
}

/**
* @return CSSFunction
*
* @throws UnexpectedEOFException
* @throws UnexpectedTokenException
*/
private static function parseMicrosoftFilter(ParserState $oParserState)
private static function parseMicrosoftFilter(ParserState $oParserState): CSSFunction
{
$sFunction = $oParserState->consumeUntil('(', false, true);
$aArguments = Value::parseValue($oParserState, [',', '=']);
Expand Down

0 comments on commit 1b4dc29

Please sign in to comment.