oyejorge / less.php

less.js ported to PHP.
http://lessphp.typesettercms.com
Apache License 2.0
655 stars 2 forks source link

PHP 7 compiler issue #317

Open seventhqueen opened 8 years ago

seventhqueen commented 8 years ago

Hi there, I tried using less.php with PHP 7 and it is always throwing an compile error. Here is an example on how it is used. Any thoughts are greatly appreciated. It is working with PHP 5.x

Thanks

    $less_files = array();
    $less_files[THEME_DIR . "/assets/less/themes/default/variables.less"] = '';
    $less_files[THEME_DIR . "/assets/less/themes/default/mixins.less"] = '';
    $less_files[THEME_DIR . "/assets/less/theme-dynamic.less"] = '';

$directories = array( THEME_DIR . "/assets/less" => '' );

try {

    $parser = new Less_Parser( $options );
    $parser->SetImportDirs( $directories );
    if (! empty( $less_files )) {
        foreach( $less_files as $k => $v ) {
            $parser->parseFile( $k, '' );
        }
    }

    $parser->ModifyVars( $variables );
    $css = $parser->getCss();
seventhqueen commented 8 years ago

Just to explain a bit more, it seems like the mixins and variables are not recognised in the last less file.

mr-russ commented 8 years ago

Without an example that we can run, it's very hard to debug this kind of issue. Supplying the compile error would also assist a little. Saying it doesn't work on PHP7 is a very difficult issue to resolve without further detail. If you can provide as much as possible that would assist in getting the issue looked at.

seventhqueen commented 8 years ago

Hello, the error is not specific and it is always about not recognising a mixin or variable. It seems like if you load the variables or mixin like I did they don't get recognised in the later less files imported. This never happens with PHP 5.x.

files.zip You can do the test with my files from the example above. I just attached them

Thanks

mr-russ commented 8 years ago

Hi, I tried those files and I wasn't able to compile them on PHP 7.0.6 without commenting out much of the imports in one of the files. When I removed all the missing file problems, it process CSS output without any failures reported. When you say the mixins are missing, what does that mean?

Are you able to give a small example that demonstrates the problem or include the full list of files in a zip with an example output on PHP7?

If you could also indicate what exactly is missing from the output that is expected that would be helpful as well.

I also had to assume what the rest of the file run looks like, which may be part of the issue. $variables is not set in that script and I don't know what if anything it should be.

Sadly there are still too many variables for me to try to determine the issue. Initial runs say that it's working but I'm sure that it's not the case for you. I'm going to have to continue to ask for more information to be able to investigate this further.

seventhqueen commented 8 years ago

Hi, thanks for taking the time to debug it. I will setup a test environment and let you know