infection
infection copied to clipboard
Allow functions to be mutated
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.