diff --git a/CHANGELOG.md b/CHANGELOG.md index 44a3697a..b7c980da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,8 @@ Please also have a look at our - Only allow `string` for some `OutputFormat` properties (#885) - Make all non-private properties `@internal` (#886) - Use more native type declarations and strict mode - (#641, #772, #774, #778, #804, #841, #873, #875, #891, #922, #923, #933) + (#641, #772, #774, #778, #804, #841, #873, #875, #891, #922, #923, #933, #958, + #964) - Add visibility to all class/interface constants (#469) ### Deprecated diff --git a/config/phpstan-baseline.neon b/config/phpstan-baseline.neon index 4fdf7a84..4150a6e8 100644 --- a/config/phpstan-baseline.neon +++ b/config/phpstan-baseline.neon @@ -120,12 +120,6 @@ parameters: count: 4 path: ../src/OutputFormat.php - - - message: '#^Parameters should have "string" types as the only types passed to this method$#' - identifier: typePerfect.narrowPublicClassMethodParamType - count: 3 - path: ../src/OutputFormatter.php - - message: '#^Default value of the parameter \#2 \$bIncludeEnd \(false\) of method Sabberworm\\CSS\\Parsing\\ParserState\:\:consumeUntil\(\) is incompatible with type string\.$#' identifier: parameter.defaultValue diff --git a/src/OutputFormat.php b/src/OutputFormat.php index 4498b34b..86b8b640 100644 --- a/src/OutputFormat.php +++ b/src/OutputFormat.php @@ -284,6 +284,7 @@ public function set($aNames, $mValue) } /** + * @param non-empty-string $sMethodName * @param array $aArguments * * @return mixed diff --git a/src/OutputFormatter.php b/src/OutputFormatter.php index c414e9e9..9f815d6f 100644 --- a/src/OutputFormatter.php +++ b/src/OutputFormatter.php @@ -19,11 +19,7 @@ public function __construct(OutputFormat $outputFormat) $this->outputFormat = $outputFormat; } - /** - * @param string $sName - * @param string|null $sType - */ - public function space($sName, $sType = null): string + public function space(string $sName, ?string $sType = null): string { $sSpaceString = $this->outputFormat->get("Space$sName"); // If $sSpaceString is an array, we have multiple values configured @@ -78,9 +74,6 @@ public function spaceBeforeSelectorSeparator(): string return $this->space('BeforeSelectorSeparator'); } - /** - * @return string - */ public function spaceAfterSelectorSeparator(): string { return $this->space('AfterSelectorSeparator'); @@ -89,7 +82,7 @@ public function spaceAfterSelectorSeparator(): string /** * @param non-empty-string $sSeparator */ - public function spaceBeforeListArgumentSeparator($sSeparator): string + public function spaceBeforeListArgumentSeparator(string $sSeparator): string { $spaceForSeparator = $this->outputFormat->getSpaceBeforeListArgumentSeparators(); @@ -99,7 +92,7 @@ public function spaceBeforeListArgumentSeparator($sSeparator): string /** * @param non-empty-string $sSeparator */ - public function spaceAfterListArgumentSeparator($sSeparator): string + public function spaceAfterListArgumentSeparator(string $sSeparator): string { $spaceForSeparator = $this->outputFormat->getSpaceAfterListArgumentSeparators(); @@ -112,13 +105,9 @@ public function spaceBeforeOpeningBrace(): string } /** - * Runs the given code, either swallowing or passing exceptions, depending on the `bIgnoreExceptions` setting. - * - * @param string $cCode the name of the function to call - * - * @return string|null + * Runs the given code, either swallowing or passing exceptions, depending on the `ignoreExceptions` setting. */ - public function safely($cCode) + public function safely(callable $cCode): ?string { if ($this->outputFormat->get('IgnoreExceptions')) { // If output exceptions are ignored, run the code with exception guards @@ -137,9 +126,8 @@ public function safely($cCode) * Clone of the `implode` function, but calls `render` with the current output format instead of `__toString()`. * * @param array $aValues - * @param bool $bIncreaseLevel */ - public function implode(string $sSeparator, array $aValues, $bIncreaseLevel = false): string + public function implode(string $sSeparator, array $aValues, bool $bIncreaseLevel = false): string { $result = ''; $outputFormat = $this->outputFormat; @@ -162,12 +150,7 @@ public function implode(string $sSeparator, array $aValues, $bIncreaseLevel = fa return $result; } - /** - * @param string $sString - * - * @return string - */ - public function removeLastSemicolon($sString) + public function removeLastSemicolon(string $sString): string { if ($this->outputFormat->get('SemicolonAfterLastRule')) { return $sString; @@ -199,17 +182,11 @@ public function comments(Commentable $oCommentable): string return $result; } - /** - * @param string $sSpaceString - */ - private function prepareSpace($sSpaceString): string + private function prepareSpace(string $sSpaceString): string { return \str_replace("\n", "\n" . $this->indent(), $sSpaceString); } - /** - * @return string - */ private function indent(): string { return \str_repeat($this->outputFormat->sIndentation, $this->outputFormat->getIndentationLevel());