diff --git a/CHANGELOG.md b/CHANGELOG.md index 4bfcf0fa..46fc107a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ Please also have a look at our ### Removed +- Remove the IE hack in `Rule` (#995) - Drop `getLineNo()` from the `Renderable` interface (#1038) - Remove `OutputFormat::level()` (#874) - Remove expansion of shorthand properties (#838) diff --git a/config/phpstan-baseline.neon b/config/phpstan-baseline.neon index f2969599..e17e1b3f 100644 --- a/config/phpstan-baseline.neon +++ b/config/phpstan-baseline.neon @@ -234,12 +234,6 @@ parameters: count: 1 path: ../src/Rule/Rule.php - - - message: '#^Construct empty\(\) is not allowed\. Use more strict comparison\.$#' - identifier: empty.notAllowed - count: 1 - path: ../src/Rule/Rule.php - - message: '#^Only booleans are allowed in an if condition, Sabberworm\\CSS\\Value\\RuleValueList\|string\|null given\.$#' identifier: if.condNotBoolean @@ -258,12 +252,6 @@ parameters: count: 1 path: ../src/Rule/Rule.php - - - message: '#^Parameters should have "string" types as the only types passed to this method$#' - identifier: typePerfect.narrowPublicClassMethodParamType - count: 1 - path: ../src/Rule/Rule.php - - message: '#^Call to an undefined method Sabberworm\\CSS\\OutputFormat\:\:comments\(\)\.$#' identifier: method.notFound diff --git a/src/Parsing/ParserState.php b/src/Parsing/ParserState.php index b4885c17..2100ed35 100644 --- a/src/Parsing/ParserState.php +++ b/src/Parsing/ParserState.php @@ -150,13 +150,6 @@ public function parseIdentifier($ignoreCase = true) public function parseCharacter($isForIdentifier) { if ($this->peek() === '\\') { - if ( - $isForIdentifier && $this->parserSettings->usesLenientParsing() - && ($this->comes('\\0') || $this->comes('\\9')) - ) { - // Non-strings can contain \0 or \9 which is an IE hack supported in lenient parsing. - return null; - } $this->consume('\\'); if ($this->comes('\\n') || $this->comes('\\r')) { return ''; diff --git a/src/Rule/Rule.php b/src/Rule/Rule.php index 45cf24d0..0ec26902 100644 --- a/src/Rule/Rule.php +++ b/src/Rule/Rule.php @@ -36,11 +36,6 @@ class Rule implements Renderable, Commentable */ private $isImportant = false; - /** - * @var array - */ - private $ieHack = []; - /** * @var int */ @@ -91,13 +86,6 @@ public static function parse(ParserState $parserState): Rule $parserState->consume(':'); $value = Value::parseValue($parserState, self::listDelimiterForRule($rule->getRule())); $rule->setValue($value); - if ($parserState->getSettings()->usesLenientParsing()) { - while ($parserState->comes('\\')) { - $parserState->consume('\\'); - $rule->addIeHack($parserState->consume()); - $parserState->consumeWhiteSpace(); - } - } $parserState->consumeWhiteSpace(); if ($parserState->comes('!')) { $parserState->consume('!'); @@ -220,30 +208,6 @@ public function addValue($value, $type = ' '): void } } - /** - * @param int $modifier - */ - public function addIeHack($modifier): void - { - $this->ieHack[] = $modifier; - } - - /** - * @param array $modifiers - */ - public function setIeHack(array $modifiers): void - { - $this->ieHack = $modifiers; - } - - /** - * @return array - */ - public function getIeHack() - { - return $this->ieHack; - } - /** * @param bool $isImportant */ @@ -276,9 +240,6 @@ public function render(OutputFormat $outputFormat): string } else { $result .= $this->value; } - if (!empty($this->ieHack)) { - $result .= ' \\' . \implode('\\', $this->ieHack); - } if ($this->isImportant) { $result .= ' !important'; } diff --git a/src/Value/Value.php b/src/Value/Value.php index dcd8686a..c14d74fa 100644 --- a/src/Value/Value.php +++ b/src/Value/Value.php @@ -50,7 +50,6 @@ public static function parseValue(ParserState $parserState, array $aListDelimite while ( !($parserState->comes('}') || $parserState->comes(';') || $parserState->comes('!') || $parserState->comes(')') - || $parserState->comes('\\') || $parserState->isEnd()) ) { if (\count($aStack) > 0) { diff --git a/tests/ParserTest.php b/tests/ParserTest.php index 7a66f852..040011b7 100644 --- a/tests/ParserTest.php +++ b/tests/ParserTest.php @@ -1036,28 +1036,6 @@ public function unexpectedTokenExceptionLineNo(): void } } - /** - * @test - */ - public function ieHacksStrictParsing(): void - { - $this->expectException(UnexpectedTokenException::class); - - // We can't strictly parse IE hacks. - self::parsedStructureForFile('ie-hacks', Settings::create()->beStrict()); - } - - /** - * @test - */ - public function ieHacksParsing(): void - { - $document = self::parsedStructureForFile('ie-hacks', Settings::create()->withLenientParsing(true)); - $expected = 'p {padding-right: .75rem \\9;background-image: none \\9;color: red \\9\\0;' - . 'background-color: red \\9\\0;background-color: red \\9\\0 !important;content: "red \\0";content: "red઼";}'; - self::assertSame($expected, $document->render()); - } - /** * @depends files * diff --git a/tests/fixtures/ie-hacks.css b/tests/fixtures/ie-hacks.css deleted file mode 100644 index 3f5f215e..00000000 --- a/tests/fixtures/ie-hacks.css +++ /dev/null @@ -1,9 +0,0 @@ -p { - padding-right: .75rem \9; - background-image: none \9; - color:red\9\0; - background-color:red \9 \0; - background-color:red \9 \0 !important; - content: "red \9\0"; - content: "red\0abc"; -}