Giter VIP home page Giter VIP logo

Comments (3)

theofidry avatar theofidry commented on May 25, 2024 1

but perhaps I'm missing something, maybe reflection is also used.

Yes :) It uses parses the AST of the source code and may leverage reflection for some mutations. It could be delegated to BetterReflection at some point, but not sure what the performance impact would be.

from infection.

theofidry avatar theofidry commented on May 25, 2024

Hi!

I would like to be able to use it with Infection, too.

I think it's a bad idea in the current state of things. As you noted, infection need to autoload your code. So if you install it in a different composer.json (which is what bamarni/composer-bin-plugin does), then you can end up with various issues:

  • The same class is declared in both infection (or its dependencies) and your project: in this case the second declaration will not be loaded (and their implementation may differ, PHP will just see "this class has been loaded already" and won't load it again).
  • Same with functions, in which case if they don't have the if (!function_exists(...)) which you will end up with declaring twice a function which crashes PHP.

Using Infection PHAR would be no different if it was a regular PHAR. However Infection uses PHP-Scoper to address those issues.

As the main contributor and a heavy user of bamarni/composer-bin-plugin, I totally understand the concern of wanting to isolate tools dependencies. However, I think this approach cannot be systematic due to the reasons outlined above. To be able to do so, you need either a tool that doesn't autoload your code, or a tool for which its code is scoped (like Infection PHAR, or like the phpstan package which ships the scoped PHPStan PHAR).

A possible solution however, would be to do like PHPStan, i.e. have a proxy package which ships the isolated PHAR. I do not know how that works with extensions though, IIRC PHPStan managed to get around with it, I do not know what it entails for Infection.

from infection.

remorhaz avatar remorhaz commented on May 25, 2024

Thank you for the fast and detailed answer!

Of course, if Infection needs to autoload project dependencies, it makes it impossible to use it with composer-bin-plugin and I'll have to switch to PHAR version; thanks to PHP-Scoper, it's possible.

But I still don't completely understand why Infection needs to load project's dependencies. I thought that it uses PHPUnit CLI to run tests and PHP-Parser to parse sources; but perhaps I'm missing something, maybe reflection is also used. Anyway, the tool is great and helps a lot.

from infection.

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.