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

Allow functions to be mutated #1482

Open
BackEndTea opened this issue Feb 17, 2021 · 0 comments · May be fixed by #1483
Open

Allow functions to be mutated #1482

BackEndTea opened this issue Feb 17, 2021 · 0 comments · May be fixed by #1483

Comments

@BackEndTea
Copy link
Member

Is your feature request related to a problem? Please describe.

Right now ( due to autoloading), infection can not mutate functions, but it can mutate methods.
e.g

function add(int $a, int $b): int 
{
  // no mutation here
  return $a + $b;
}

class Calculator
{
  function add(int $a, int $b): int 
  {
    // + is mutated to -
    return $a + $b;
  }
}

Currently the Interceptor is registered in the bootstrap file, so it will work as follows:

  • vendor/bin/phpunit
  • autoloader gets registered
    • all functions are autoloaded
  • phpunit executes bootstrap file
    • interceptor is registered
  • Interceptor intercepts autoloader

Describe the solution you'd like

If we move the registering of the interceptor before the autoloader is registered, we can mutate functions, as we intercept the autoloading before they are autoloaded.

We could have our own php script, instead of running the original one, like so:

<?php

require_once "path_to_interceptor";

IncludeInterceptor::intercept('{$originalFilePath}', '{$mutantFilePath}');
IncludeInterceptor::enable();

require_once "original_executable"

Describe alternatives you've considered
N/A

Additional context
Add any other context or screenshots about the feature request here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant