Giter Club home page Giter Club logo

Comments (10)

jeremeamia avatar jeremeamia commented on August 16, 2024

Thanks. I'll take a look at it when I have time. That may be a couple months from now though, so feel free to send a PR if you have time.

from super_closure.

divostar avatar divostar commented on August 16, 2024

Okay

from super_closure.

GrahamCampbell avatar GrahamCampbell commented on August 16, 2024

We can just do the same as what class preloader has done?

from super_closure.

GrahamCampbell avatar GrahamCampbell commented on August 16, 2024

Wait, our code already does this. How come this is nor working for you. That code never gets called on 2.x?

from super_closure.

GrahamCampbell avatar GrahamCampbell commented on August 16, 2024

Our code looks like this:

    /**
     * @param \ReflectionFunction $reflection
     *
     * @throws ClosureAnalysisException
     *
     * @return \PhpParser\Node[]
     */
    private function getFileAst(\ReflectionFunction $reflection)
    {
        $fileName = $reflection->getFileName();
        if (!file_exists($fileName)) {
            throw new ClosureAnalysisException(
                "The file containing the closure, \"{$fileName}\" did not exist."
            );
        }


        return $this->getParser()->parse(file_get_contents($fileName));
    }

    /**
     * @return CodeParser
     */
    private function getParser()
    {
        if (class_exists('PhpParser\ParserFactory')) {
            return (new ParserFactory)->create(ParserFactory::PREFER_PHP7);
        }

        return new CodeParser(new EmulativeLexer);
    }

The bottom line is only ever called on php parser 1.x.

from super_closure.

GrahamCampbell avatar GrahamCampbell commented on August 16, 2024

Are you noticing this issue due to a static analzyer, or due to it actually happening?

from super_closure.

divostar avatar divostar commented on August 16, 2024

I was experiencing the issue with nikic/php-parser v2.1.0 and jeremeamia/SuperClosure 2.2.0 on my production server but not on my development server (which is weird). For a quick fix in my production server, I had to use v1.4.1 of php parser. Out of curiosity, I tested SuperClosure 2.2.0 and php-parser v2.1.0 on another project on thesame production server and wasn't getting the exception. When I open your code in PhpStorm, I notice that the bottom line is underlined with
the error "Cannot Instantiate Interface Parser" thesame exception that was displayed when I was using nikic/php-parser v2.1.0 and jeremeamia/SuperClosure 2.2.0 on the prod server.

from super_closure.

GrahamCampbell avatar GrahamCampbell commented on August 16, 2024

DId you restart/reload php-fpm after deploying?

from super_closure.

GrahamCampbell avatar GrahamCampbell commented on August 16, 2024

It looks like you just have stale caches on the productyion server.

from super_closure.

divostar avatar divostar commented on August 16, 2024

Let me reload and see what I get.

from super_closure.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.