Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect JIT behaviour with unusual PHP syntax #70

Closed
tyranron opened this issue Jul 27, 2015 · 4 comments
Closed

Incorrect JIT behaviour with unusual PHP syntax #70

tyranron opened this issue Jul 27, 2015 · 4 comments
Labels

Comments

@tyranron
Copy link
Collaborator

For situation like

it('falls', function () {
    $pdf = new \mPDF();
});

Kahlan outputs

PHP Parse error:  syntax error, unexpected '}' in /path/to/temp/dir/kahlan/project/vendor/mpdf/mpdf/mpdf.php on line 1981

If we look into this file at this line we will see:

    if ($this->bodyBackgroundColor) {
        $s .= 'q ' .$this->SetFColor($this->bodyBackgroundColor, true)."\n";
        if ($this->bodyBackgroundColor{}0==5) { // RGBa
            $s .= $this->SetAlpha($__KMONKEY__123($this->bodyBackgroundColor{4})/100, 'Normal', true, 'F')."\n";
        }
        else if ($this->bodyBackgroundColor{}0==6) {    // CMYKa
            $s .= $this->SetAlpha($__KMONKEY__124($this->bodyBackgroundColor{5})/100, 'Normal', true, 'F')."\n";
        }
        $s .= $__KMONKEY__125('%.3F %.3F %.3F %.3F re f Q', ($clx*_MPDFK), ($cly*_MPDFK),$clw*_MPDFK,$clh*_MPDFK)."\n";
    }

At the same time the original file is:

    if ($this->bodyBackgroundColor) {
        $s .= 'q ' .$this->SetFColor($this->bodyBackgroundColor, true)."\n";
        if ($this->bodyBackgroundColor{0}==5) { // RGBa
            $s .= $this->SetAlpha(ord($this->bodyBackgroundColor{4})/100, 'Normal', true, 'F')."\n";
        }
        else if ($this->bodyBackgroundColor{0}==6) {    // CMYKa
            $s .= $this->SetAlpha(ord($this->bodyBackgroundColor{5})/100, 'Normal', true, 'F')."\n";
        }
        $s .= sprintf('%.3F %.3F %.3F %.3F re f Q', ($clx*_MPDFK), ($cly*_MPDFK),$clw*_MPDFK,$clh*_MPDFK)."\n";
    }

The problem is in that string:

if ($this->bodyBackgroundColor{}0==5) { // RGBa

Version of Kahlan: 1.1.5 (d78b421)
Version of mPDF: v6.0.0 (a15743d030ce3b5b7be36c6e83f76589b27c3f2c)

@jails
Copy link
Contributor

jails commented Jul 27, 2015

Nice find.
I fixed it in the JIT repo crysalead/jit@04faf06

@jails jails closed this as completed Jul 27, 2015
@tyranron
Copy link
Collaborator Author

@jails so fast...as usual =) Thank you.
May I ask you to release new minor version? This fix is quite important for me.

@jails
Copy link
Contributor

jails commented Jul 27, 2015

Since kahlan depends on "crysalead/jit": "~1.0" a simple composer update should update the JIT library to the fixed version.
Anyhow I'll also create a new tag for Kahlan anytime soon.

@tyranron
Copy link
Collaborator Author

@jails didn't notice that possibility...thanks for tip!

@jails jails added the bug label Sep 1, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants