sabberworm / PHP-CSS-Parser

A Parser for CSS Files written in PHP. Allows extraction of CSS files into a data structure, manipulation of said structure and output as (optimized) CSS

Home Page:http://www.sabberworm.com/blog/2010/6/10/php-css-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Strict parsing mode exception with whitespace-only CSS

JakeQZ opened this issue · comments

In the following test, only the empty string passes:

    public function provideEmptyCss()
    {
        return [
            'empty string' => [''],
            'space' => [' '],
            'newline' => ["\n"],
            'carriage return' => ["\r"],
            'tab' => ["\t"],
            'Windows line ending' => ["\r\n"],
            'comment' => ['/**/'],
        ];
    }

    /**
     * @test
     *
     * @dataProvider provideEmptyCss
     */
    public function parsesEmptyCssInStrictMode($css)
    {
        $oParser = new Parser($css, Settings::create()->beStrict());

        self::assertSame('', $oParser->parse()->render());
    }

The others fail:

Sabberworm\CSS\Parsing\UnexpectedEOFException: Next token was expected to have 1 chars. Context: “”. [line no: 1]

D:\Data\dev\PHP-CSS-Parser\src\Parsing\ParserState.php:279
D:\Data\dev\PHP-CSS-Parser\src\RuleSet\DeclarationBlock.php:58
D:\Data\dev\PHP-CSS-Parser\src\CSSList\CSSList.php:146
D:\Data\dev\PHP-CSS-Parser\src\CSSList\CSSList.php:82
D:\Data\dev\PHP-CSS-Parser\src\CSSList\Document.php:35
D:\Data\dev\PHP-CSS-Parser\src\Parser.php:58
D:\Data\dev\PHP-CSS-Parser\tests\ParserTest.php:90

The lenient-mode equivalent test passes fine, however.

ezoic increase your site revenue