Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/RuleSet/DeclarationBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -216,29 +216,29 @@ public function addRule(Rule $ruleToAdd, ?Rule $sibling = null): void
}

/**
* @see RuleSet::getRules()
*
* @return array<int<0, max>, Rule>
*
* @see RuleSet::getRules()
*/
public function getRules(?string $searchPattern = null): array
{
return $this->ruleSet->getRules($searchPattern);
}

/**
* @see RuleSet::setRules()
*
* @param array<Rule> $rules
*
* @see RuleSet::setRules()
*/
public function setRules(array $rules): void
{
$this->ruleSet->setRules($rules);
}

/**
* @see RuleSet::getRulesAssoc()
*
* @return array<string, Rule>
*
* @see RuleSet::getRulesAssoc()
*/
public function getRulesAssoc(?string $searchPattern = null): array
{
Expand Down
14 changes: 10 additions & 4 deletions tests/Comment/CommentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ final class CommentTest extends TestCase
public function keepCommentsInOutput(): void
{
$cssDocument = TestsParserTest::parsedStructureForFile('comments');
self::assertSame('/** Number 11 **/
self::assertSame(
'/** Number 11 **/

/**
* Comments
Expand All @@ -43,7 +44,9 @@ public function keepCommentsInOutput(): void
position: absolute;
}
}
', $cssDocument->render(OutputFormat::createPretty()));
',
$cssDocument->render(OutputFormat::createPretty())
);
self::assertSame(
'/** Number 11 **//**' . "\n"
. ' * Comments' . "\n"
Expand All @@ -61,7 +64,8 @@ public function keepCommentsInOutput(): void
public function stripCommentsFromOutput(): void
{
$css = TestsParserTest::parsedStructureForFile('comments');
self::assertSame('
self::assertSame(
'
@import url("some/url.css") screen;

.foo, #bar {
Expand All @@ -73,7 +77,9 @@ public function stripCommentsFromOutput(): void
position: absolute;
}
}
', $css->render(OutputFormat::createPretty()->setRenderComments(false)));
',
$css->render(OutputFormat::createPretty()->setRenderComments(false))
);
self::assertSame(
'@import url("some/url.css") screen;'
. '.foo,#bar{background-color:#000}'
Expand Down
34 changes: 22 additions & 12 deletions tests/OutputFormatTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ final class OutputFormatTest extends TestCase
/**
* @var string
*/
private const TEST_CSS = <<<EOT

private const TEST_CSS = '
.main, .test {
font: italic normal bold 16px/1.2 "Helvetica", Verdana, sans-serif;
background: white;
Expand All @@ -32,8 +31,7 @@ final class OutputFormatTest extends TestCase
background-color: #fff;
}
}

EOT;
';

/**
* @var Parser
Expand Down Expand Up @@ -187,15 +185,18 @@ public function spaceRules(): void
->setSpaceBetweenRules("\n")
->setSpaceAfterRules("\n");

self::assertSame('.main, .test {
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));
}}',
$this->document->render($outputFormat)
);
}

/**
Expand All @@ -208,12 +209,15 @@ public function spaceBlocks(): void
->setSpaceBetweenBlocks("\n")
->setSpaceAfterBlocks("\n");

self::assertSame('
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));
',
$this->document->render($outputFormat)
);
}

/**
Expand All @@ -229,7 +233,8 @@ public function spaceBoth(): void
->setSpaceBetweenBlocks("\n")
->setSpaceAfterBlocks("\n");

self::assertSame('
self::assertSame(
'
.main, .test {
font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;
background: white;
Expand All @@ -241,7 +246,9 @@ public function spaceBoth(): void
background-color: #fff;
}
}
', $this->document->render($outputFormat));
',
$this->document->render($outputFormat)
);
}

/**
Expand Down Expand Up @@ -273,7 +280,8 @@ public function indentation(): void
->setSpaceAfterBlocks("\n")
->setIndentation('');

self::assertSame('
self::assertSame(
'
.main, .test {
font: italic normal bold 16px/1.2 "Helvetica",Verdana,sans-serif;
background: white;
Expand All @@ -285,7 +293,9 @@ public function indentation(): void
background-color: #fff;
}
}
', $this->document->render($outputFormat));
',
$this->document->render($outputFormat)
);
}

/**
Expand Down
8 changes: 4 additions & 4 deletions tests/ParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -571,10 +571,10 @@ public function comments(): void
{
$document = self::parsedStructureForFile('comments');
$expected = <<<EXPECTED
@import url("some/url.css") screen;
.foo, #bar {background-color: #000;}
@media screen {#foo.bar {position: absolute;}}
EXPECTED;
@import url("some/url.css") screen;
.foo, #bar {background-color: #000;}
@media screen {#foo.bar {position: absolute;}}
EXPECTED;
Comment on lines +574 to +577
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indenting this will probably break the test, because it will include the additional whitespace in the expected result. For readability, it might be better constructing the string by concatenating substrings.

The Lint failure in PHP 7.2 is because the heredoc closing identifier must be at the beginning of the line. From the docs:

The closing identifier may be indented by space or tab, in which case the indentation will be stripped from all lines in the doc string. Prior to PHP 7.3.0, the closing identifier must begin in the first column of the line.

So actually, indenting this will not break the tests for PHP >= 7.3, but will for PHP 7.2.

self::assertSame($expected, $document->render());
}

Expand Down
Loading