alexandrmazur96 / php-code-minifier

PHP Code Minifier is a tool that allows you to minify your PHP code.
MIT License
3 stars 2 forks source link

Heredoc and Nowdoc are not minified correctly. #2

Open RobertWesner opened 3 weeks ago

RobertWesner commented 3 weeks ago

Reproduce with:

Demo.php

<?php

class Demo
{
    public static function test(): string
    {
        return <<<'EOF'
        This is the first line!
        I am a nowdoc.
        Everything is just fine.
        The end is near.
        EOF;
    }
}

test.php

<?php

use PhpCodeMinifier\MinifierFactory;

require __DIR__ . '/vendor/autoload.php';

echo (new MinifierFactory())->create()->minifyFile(__DIR__ . '/Demo.php');

results in:

<?php class Demo{public static function test():string{return <<<'EOF'         This is the first line!
        I am a nowdoc.
        Everything is just fine.
        The end is near.
 EOF;}}

expected:

<?php class Demo{public static function test():string{return <<<'EOF'
This is the first line!
I am a nowdoc.
Everything is just fine.
The end is near.
EOF;}}

It fails with both pre 7.3 syntax and >=7.3 syntax.

RobertWesner commented 3 weeks ago

Created a pull request to fix the issue.