diff --git a/config/phpstan-baseline.neon b/config/phpstan-baseline.neon index 6c8029378..43f97d194 100644 --- a/config/phpstan-baseline.neon +++ b/config/phpstan-baseline.neon @@ -102,12 +102,6 @@ parameters: count: 2 path: ../src/CSSList/KeyFrame.php - - - message: '#^Parameters should have "string\|string" types as the only types passed to this method$#' - identifier: typePerfect.narrowPublicClassMethodParamType - count: 1 - path: ../src/OutputFormat.php - - message: '#^Returning false in non return bool class method\. Use null with type\|null instead or add bool return type$#' identifier: typePerfect.nullOverFalse diff --git a/tests/OutputFormatTest.php b/tests/OutputFormatTest.php index c9d7b068c..3679245d6 100644 --- a/tests/OutputFormatTest.php +++ b/tests/OutputFormatTest.php @@ -182,6 +182,11 @@ public function spaceAfterRuleName(): void */ public function spaceRules(): void { + $outputFormat = OutputFormat::create() + ->setSpaceBeforeRules("\n") + ->setSpaceBetweenRules("\n") + ->setSpaceAfterRules("\n"); + self::assertSame('.main, .test { font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif; background: white; @@ -190,7 +195,7 @@ public function spaceRules(): void background-size: 100% 100%; font-size: 1.3em; background-color: #fff; - }}', $this->document->render(OutputFormat::create()->set('Space*Rules', "\n"))); + }}', $this->document->render($outputFormat)); } /** @@ -198,12 +203,17 @@ public function spaceRules(): void */ public function spaceBlocks(): void { + $outputFormat = OutputFormat::create() + ->setSpaceBeforeBlocks("\n") + ->setSpaceBetweenBlocks("\n") + ->setSpaceAfterBlocks("\n"); + self::assertSame(' .main, .test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;} @media screen { .main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;} } -', $this->document->render(OutputFormat::create()->set('Space*Blocks', "\n"))); +', $this->document->render($outputFormat)); } /** @@ -211,6 +221,14 @@ public function spaceBlocks(): void */ public function spaceBoth(): void { + $outputFormat = OutputFormat::create() + ->setSpaceBeforeRules("\n") + ->setSpaceBetweenRules("\n") + ->setSpaceAfterRules("\n") + ->setSpaceBeforeBlocks("\n") + ->setSpaceBetweenBlocks("\n") + ->setSpaceAfterBlocks("\n"); + self::assertSame(' .main, .test { font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif; @@ -223,7 +241,7 @@ public function spaceBoth(): void background-color: #fff; } } -', $this->document->render(OutputFormat::create()->set('Space*Rules', "\n")->set('Space*Blocks', "\n"))); +', $this->document->render($outputFormat)); } /** @@ -231,10 +249,13 @@ public function spaceBoth(): void */ public function spaceBetweenBlocks(): void { + $outputFormat = OutputFormat::create() + ->setSpaceBetweenBlocks(''); + self::assertSame( '.main, .test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;}' . '@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}', - $this->document->render(OutputFormat::create()->setSpaceBetweenBlocks('')) + $this->document->render($outputFormat) ); } @@ -243,6 +264,15 @@ public function spaceBetweenBlocks(): void */ public function indentation(): void { + $outputFormat = OutputFormat::create() + ->setSpaceBeforeRules("\n") + ->setSpaceBetweenRules("\n") + ->setSpaceAfterRules("\n") + ->setSpaceBeforeBlocks("\n") + ->setSpaceBetweenBlocks("\n") + ->setSpaceAfterBlocks("\n") + ->setIndentation(''); + self::assertSame(' .main, .test { font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif; @@ -255,10 +285,7 @@ public function indentation(): void background-color: #fff; } } -', $this->document->render(OutputFormat::create() - ->set('Space*Rules', "\n") - ->set('Space*Blocks', "\n") - ->setIndentation(''))); +', $this->document->render($outputFormat)); } /** @@ -266,10 +293,13 @@ public function indentation(): void */ public function spaceBeforeBraces(): void { + $outputFormat = OutputFormat::create() + ->setSpaceBeforeOpeningBrace(''); + self::assertSame( '.main, .test{font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;} @media screen{.main{background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}', - $this->document->render(OutputFormat::create()->setSpaceBeforeOpeningBrace('')) + $this->document->render($outputFormat) ); } @@ -280,16 +310,18 @@ public function ignoreExceptionsOff(): void { $this->expectException(OutputException::class); + $outputFormat = OutputFormat::create()->setIgnoreExceptions(false); + $declarationBlocks = $this->document->getAllDeclarationBlocks(); $firstDeclarationBlock = $declarationBlocks[0]; $firstDeclarationBlock->removeSelector('.main'); self::assertSame( '.test {font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;background: white;} @media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}', - $this->document->render(OutputFormat::create()->setIgnoreExceptions(false)) + $this->document->render($outputFormat) ); $firstDeclarationBlock->removeSelector('.test'); - $this->document->render(OutputFormat::create()->setIgnoreExceptions(false)); + $this->document->render($outputFormat); } /** @@ -297,13 +329,15 @@ public function ignoreExceptionsOff(): void */ public function ignoreExceptionsOn(): void { + $outputFormat = OutputFormat::create()->setIgnoreExceptions(true); + $declarationBlocks = $this->document->getAllDeclarationBlocks(); $firstDeclarationBlock = $declarationBlocks[0]; $firstDeclarationBlock->removeSelector('.main'); $firstDeclarationBlock->removeSelector('.test'); self::assertSame( '@media screen {.main {background-size: 100% 100%;font-size: 1.3em;background-color: #fff;}}', - $this->document->render(OutputFormat::create()->setIgnoreExceptions(true)) + $this->document->render($outputFormat) ); } }