diff --git a/config/phpstan-baseline.neon b/config/phpstan-baseline.neon index a7a2f2117..846a8dfe4 100644 --- a/config/phpstan-baseline.neon +++ b/config/phpstan-baseline.neon @@ -1,8 +1,3 @@ parameters: - ignoreErrors: - - - message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:setIndentation\(\)\.$#' - identifier: method.notFound - count: 2 - path: ../src/OutputFormat.php + ignoreErrors: [] diff --git a/src/OutputFormat.php b/src/OutputFormat.php index 1722b7384..979f600a1 100644 --- a/src/OutputFormat.php +++ b/src/OutputFormat.php @@ -4,12 +4,6 @@ namespace Sabberworm\CSS; -/** - * Class OutputFormat - * - * @method OutputFormat setSemicolonAfterLastRule(bool $bSemicolonAfterLastRule) Set whether semicolons are added after - * last rule. - */ class OutputFormat { /** @@ -251,17 +245,483 @@ public function set($aNames, $mValue) */ public function __call(string $sMethodName, array $aArguments) { - if (\strpos($sMethodName, 'set') === 0) { - return $this->set(\substr($sMethodName, 3), $aArguments[0]); - } elseif (\strpos($sMethodName, 'get') === 0) { - return $this->get(\substr($sMethodName, 3)); - } elseif (\method_exists(OutputFormatter::class, $sMethodName)) { + if (\method_exists(OutputFormatter::class, $sMethodName)) { return \call_user_func_array([$this->getFormatter(), $sMethodName], $aArguments); } else { throw new \Exception('Unknown OutputFormat method called: ' . $sMethodName); } } + /** + * @internal + */ + public function getStringQuotingType(): string + { + return $this->sStringQuotingType; + } + + /** + * @return $this fluent interface + */ + public function setStringQuotingType(string $quotingType): self + { + $this->sStringQuotingType = $quotingType; + + return $this; + } + + /** + * @internal + */ + public function getRGBHashNotation(): bool + { + return $this->bRGBHashNotation; + } + + /** + * @return $this fluent interface + */ + public function setRGBHashNotation(bool $rgbHashNotation): self + { + $this->bRGBHashNotation = $rgbHashNotation; + + return $this; + } + + /** + * @internal + */ + public function getSemicolonAfterLastRule(): bool + { + return $this->bSemicolonAfterLastRule; + } + + /** + * @return $this fluent interface + */ + public function setSemicolonAfterLastRule(bool $semicolonAfterLastRule): self + { + $this->bSemicolonAfterLastRule = $semicolonAfterLastRule; + + return $this; + } + + /** + * @internal + */ + public function getSpaceAfterRuleName(): string + { + return $this->sSpaceAfterRuleName; + } + + /** + * @return $this fluent interface + */ + public function setSpaceAfterRuleName(string $whitespace): self + { + $this->sSpaceAfterRuleName = $whitespace; + + return $this; + } + + /** + * @internal + */ + public function getSpaceBeforeRules(): string + { + return $this->sSpaceBeforeRules; + } + + /** + * @return $this fluent interface + */ + public function setSpaceBeforeRules(string $whitespace): self + { + $this->sSpaceBeforeRules = $whitespace; + + return $this; + } + + /** + * @internal + */ + public function getSpaceAfterRules(): string + { + return $this->sSpaceAfterRules; + } + + /** + * @return $this fluent interface + */ + public function setSpaceAfterRules(string $whitespace): self + { + $this->sSpaceAfterRules = $whitespace; + + return $this; + } + + /** + * @internal + */ + public function getSpaceBetweenRules(): string + { + return $this->sSpaceBetweenRules; + } + + /** + * @return $this fluent interface + */ + public function setSpaceBetweenRules(string $whitespace): self + { + $this->sSpaceBetweenRules = $whitespace; + + return $this; + } + + /** + * @internal + */ + public function getSpaceBeforeBlocks(): string + { + return $this->sSpaceBeforeBlocks; + } + + /** + * @return $this fluent interface + */ + public function setSpaceBeforeBlocks(string $whitespace): self + { + $this->sSpaceBeforeBlocks = $whitespace; + + return $this; + } + + /** + * @internal + */ + public function getSpaceAfterBlocks(): string + { + return $this->sSpaceAfterBlocks; + } + + /** + * @return $this fluent interface + */ + public function setSpaceAfterBlocks(string $whitespace): self + { + $this->sSpaceAfterBlocks = $whitespace; + + return $this; + } + + /** + * @internal + */ + public function getSpaceBetweenBlocks(): string + { + return $this->sSpaceBetweenBlocks; + } + + /** + * @return $this fluent interface + */ + public function setSpaceBetweenBlocks(string $whitespace): self + { + $this->sSpaceBetweenBlocks = $whitespace; + + return $this; + } + + /** + * @internal + */ + public function getBeforeAtRuleBlock(): string + { + return $this->sBeforeAtRuleBlock; + } + + /** + * @return $this fluent interface + */ + public function setBeforeAtRuleBlock(string $content): self + { + $this->sBeforeAtRuleBlock = $content; + + return $this; + } + + /** + * @internal + */ + public function getAfterAtRuleBlock(): string + { + return $this->sAfterAtRuleBlock; + } + + /** + * @return $this fluent interface + */ + public function setAfterAtRuleBlock(string $content): self + { + $this->sAfterAtRuleBlock = $content; + + return $this; + } + + /** + * @internal + */ + public function getSpaceBeforeSelectorSeparator(): string + { + return $this->sSpaceBeforeSelectorSeparator; + } + + /** + * @return $this fluent interface + */ + public function setSpaceBeforeSelectorSeparator(string $whitespace): self + { + $this->sSpaceBeforeSelectorSeparator = $whitespace; + + return $this; + } + + /** + * @internal + */ + public function getSpaceAfterSelectorSeparator(): string + { + return $this->sSpaceAfterSelectorSeparator; + } + + /** + * @return $this fluent interface + */ + public function setSpaceAfterSelectorSeparator(string $whitespace): self + { + $this->sSpaceAfterSelectorSeparator = $whitespace; + + return $this; + } + + /** + * @internal + */ + public function getSpaceBeforeListArgumentSeparator(): string + { + return $this->sSpaceBeforeListArgumentSeparator; + } + + /** + * @return $this fluent interface + */ + public function setSpaceBeforeListArgumentSeparator(string $whitespace): self + { + $this->sSpaceBeforeListArgumentSeparator = $whitespace; + + return $this; + } + + /** + * @return array + * + * @internal + */ + public function getSpaceBeforeListArgumentSeparators(): array + { + return $this->aSpaceBeforeListArgumentSeparators; + } + + /** + * @param array $separatorSpaces + * + * @return $this fluent interface + */ + public function setSpaceBeforeListArgumentSeparators(array $separatorSpaces): self + { + $this->aSpaceBeforeListArgumentSeparators = $separatorSpaces; + + return $this; + } + + /** + * @return string|array + * + * @internal + */ + public function getSpaceAfterListArgumentSeparator() + { + return $this->sSpaceAfterListArgumentSeparator; + } + + /** + * @param string|array $whitespace + * + * @return $this fluent interface + */ + public function setSpaceAfterListArgumentSeparator($whitespace): self + { + $this->sSpaceAfterListArgumentSeparator = $whitespace; + + return $this; + } + + /** + * @return array + * + * @internal + */ + public function getSpaceAfterListArgumentSeparators(): array + { + return $this->aSpaceAfterListArgumentSeparators; + } + + /** + * @param array $separatorSpaces + * + * @return $this fluent interface + */ + public function setSpaceAfterListArgumentSeparators(array $separatorSpaces): self + { + $this->aSpaceAfterListArgumentSeparators = $separatorSpaces; + + return $this; + } + + /** + * @internal + */ + public function getSpaceBeforeOpeningBrace(): string + { + return $this->sSpaceBeforeOpeningBrace; + } + + /** + * @return $this fluent interface + */ + public function setSpaceBeforeOpeningBrace(string $whitespace): self + { + $this->sSpaceBeforeOpeningBrace = $whitespace; + + return $this; + } + + /** + * @internal + */ + public function getBeforeDeclarationBlock(): string + { + return $this->sBeforeDeclarationBlock; + } + + /** + * @return $this fluent interface + */ + public function setBeforeDeclarationBlock(string $content): self + { + $this->sBeforeDeclarationBlock = $content; + + return $this; + } + + /** + * @internal + */ + public function getAfterDeclarationBlockSelectors(): string + { + return $this->sAfterDeclarationBlockSelectors; + } + + /** + * @return $this fluent interface + */ + public function setAfterDeclarationBlockSelectors(string $content): self + { + $this->sAfterDeclarationBlockSelectors = $content; + + return $this; + } + + /** + * @internal + */ + public function getAfterDeclarationBlock(): string + { + return $this->sAfterDeclarationBlock; + } + + /** + * @return $this fluent interface + */ + public function setAfterDeclarationBlock(string $content): self + { + $this->sAfterDeclarationBlock = $content; + + return $this; + } + + /** + * @internal + */ + public function getIndentation(): string + { + return $this->sIndentation; + } + + /** + * @return $this fluent interface + */ + public function setIndentation(string $indentation): self + { + $this->sIndentation = $indentation; + + return $this; + } + + /** + * @internal + */ + public function getIgnoreExceptions(): bool + { + return $this->bIgnoreExceptions; + } + + /** + * @return $this fluent interface + */ + public function setIgnoreExceptions(bool $ignoreExceptions): self + { + $this->bIgnoreExceptions = $ignoreExceptions; + + return $this; + } + + /** + * @internal + */ + public function getRenderComments(): bool + { + return $this->bRenderComments; + } + + /** + * @return $this fluent interface + */ + public function setRenderComments(bool $renderComments): self + { + $this->bRenderComments = $renderComments; + + return $this; + } + + /** + * @internal + */ + public function getIndentationLevel(): int + { + return $this->iIndentationLevel; + } + /** * @return $this fluent interface */ diff --git a/tests/Unit/OutputFormatTest.php b/tests/Unit/OutputFormatTest.php index 2e5abce92..79ff27129 100644 --- a/tests/Unit/OutputFormatTest.php +++ b/tests/Unit/OutputFormatTest.php @@ -721,25 +721,6 @@ public function getIndentationLevelInitiallyReturnsZero(): void self::assertSame(0, $this->subject->getIndentationLevel()); } - /** - * @test - */ - public function setIndentationLevelSetsIndentationLevel(): void - { - $value = 4; - $this->subject->setIndentationLevel($value); - - self::assertSame($value, $this->subject->getIndentationLevel()); - } - - /** - * @test - */ - public function setIndentationLevelProvidesFluentInterface(): void - { - self::assertSame($this->subject, $this->subject->setIndentationLevel(4)); - } - /** * @test */ @@ -850,8 +831,7 @@ public function nextLevelReturnsDifferentInstance(): void */ public function nextLevelReturnsInstanceWithIndentationLevelIncreasedByOne(): void { - $originalIndentationLevel = 2; - $this->subject->setIndentationLevel($originalIndentationLevel); + $originalIndentationLevel = $this->subject->getIndentationLevel(); self::assertSame($originalIndentationLevel + 1, $this->subject->nextLevel()->getIndentationLevel()); }