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

The problem in PHP8 #348

Closed
mitsh opened this issue Jan 11, 2021 · 7 comments
Closed

The problem in PHP8 #348

mitsh opened this issue Jan 11, 2021 · 7 comments

Comments

@mitsh
Copy link

mitsh commented Jan 11, 2021

This issue has appeared after upgrading to PHP8.

Parse error: syntax error, unexpected token "*" in /tmp/lci_7myMwD on line 2

I did a search and found the problem and I made a change in this file;
./src/vendor/lightncandy/Exporter.php

/**
 * Get metadata from ReflectionObject
 *
 * @param object $refobj instance of the ReflectionObject
 *
 * @return array
 */
public static function getMeta($refobj)
{
    $fname = $refobj->getFileName();
    $lines = file_get_contents($fname);
    $file = new \SplFileObject($fname);
    // $file->seek($refobj->getStartLine() - 2);     <-- this is the old one
    $file->seek($refobj->getStartLine() - 1);
    $spos = $file->ftell();
    //     $file->seek($refobj->getEndLine() - 1);   <-- this is the old one
    $file->seek($refobj->getEndLine());
    $epos = $file->ftell();
    unset($file);
    return array(
        'name' => $refobj->getName(),
        'code' => substr($lines, $spos, $epos - $spos)
    );
}

Is this a correct way to fix it?

@VascularEngineer
Copy link

This is also helping for me. I'm also on php 8. Not sure if it is the right way to go, I hope we get some feedback on that.
I had a similar error, mine was

CRITICAL: Uncaught Exception ParseError: "syntax error, unexpected token ","" at /tmp/lci_Z3NgN8 line 14 {"exception":"[object] (ParseError(code: 0): syntax error, unexpected token "," at /tmp/lci_Z3NgN8:14)"}

@yurikuzn
Copy link
Contributor

My fix. Not tested enough yet: yurikuzn@207d424

@danmcadams
Copy link

I actually came across this and ended up doing the same thing you did. The problem is the change isn't backwards compatible.

@cleoclatskid
Copy link

Just tried out the above fix yurikuzn/lightncandy@207d424
and it works nicely!
Thanks

@kohlerdominik
Copy link

My fix. Not tested enough yet: yurikuzn@207d424

Works for me, too. Can you make a PR from this @yurikuzn ?

@yurikuzn
Copy link
Contributor

Done: #351

@mitsh
Copy link
Author

mitsh commented Jun 25, 2021

@yurikuzn's approach is more compatible than mine. so, we can close this issue.

@mitsh mitsh closed this as completed Jun 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants