Profiles

Infection supports the use of mutator profiles for the command line and configuration file.

The following configuration file will use the @default profile, but turn off the @function_signature profile.
On top of that, it does not apply the TrueValue mutator on any classes that match the provided ignore patterns. In particular, TrueValue mutator does not mutate the code inside Full\NameSpaced\Class class and inside create() method of all SourceClass classes. Finally, the MethodCallRemoval mutator will ignore line 63 of AnotherClass in the method doSomething. Specifying the line gives the ability to ignore one instance in a method, but still process other instances in the same method.

global-ignore allows to apply the ignore setting to all mutators & profiles registered. If ignore is specified for a given profile or mutator, it will be merged with global-ignore. For example, in the case below the final ignore setting for TrueValue will be:

[
"FooClass::__construct",
"NameSpace\\*\\SourceClass::create",
"Full\\NameSpaced\\Class"
]

global-ignoreSourceCodeByRegex allows to apply the ignoreSourceCodeByRegex setting to all mutators & profiles registered and works similar to global-ignore setting.

Read more about ignore and ignoreSourceCodeByRegex settings

These ignores can also be added to profiles, to ensure Infection is as flexible as you need it.

All profiles are prepended by an @ and in snake case, while all mutators are in PascalCase.

{
"source": {
"directories": [
"src"
]
},
"timeout": 10,
"logs": {
"text": "infection.log"
},
"mutators": {
"global-ignore": [
"FooClass::__construct"
],
"global-ignoreSourceCodeByRegex": [
"Assert::.*"
],
"@default": true,
"@function_signature": false,
"TrueValue": {
"ignore": [
"NameSpace\\*\\SourceClass::create",
"Full\\NameSpaced\\Class"
],
"ignoreSourceCodeByRegex": [
"\\$this->logger.*"
]
},
"MethodCallRemoval": {
"ignore": [
"AnotherClass::doSomething::63"
]
}
}
}

The Profiles

Currently, infection supports the following profiles:

@arithmetic

Contains the following mutators:

@boolean

Contains the following mutators:

@cast

Contains the following mutators:

@conditional_boundary

Contains the following mutators:

@conditional_negotiation

Contains the following mutators:

@equal

Contains the following mutators:

@function_signature

Contains the following mutators:

@identical

Contains the following mutators:

@number

Contains the following mutators:

@operator

Contains the following mutators:

@regex

Contains the following mutators:

@removal

Contains the following mutators:

@return_value

Contains the following mutators:

@sort

Contains the following mutators:

@unwrap

Contains the following mutators:

@zero_iteration

Contains the following mutators:

@extensions

Contains the following mutators:

@default

This is the default profile, which currently contains most mutators, and is used if no mutator or profile is chosen.

Feel free to request a new profile to be added in Github’s issues.