What's new in Infection 0.13.0

May 18, 2019

Release: https://github.com/infection/infection/releases/tag/0.13.0

New features and enhancements

Proper array coverage

As shown on the image below, array coverage is a bit wonky in PHP, and not all items are considered covered.

array coverage

Before 0.13.0, mutants, created from not covered lines could not be killed.

Now, even with such coverage results, Infection will treat those white lines as covered so you can kill generated Mutants.

pcov support

We’ve added a preliminary support for pcov - quite new CodeCoverage compatible driver for PHP.

Ignore mutator on particular line of the code

It was possible to disable (ignore) mutators for classes and methods using wildcards.

Now it’s also possible to disable mutators just for one line of the code:

"mutators": {
"MethodCallRemoval": {
"ignore": [

--no-progress option (automatically enabled on CI server)

The amount of text generated by the initial processes (running tests, generating mutations) is quite big, specially when running it on medium to large projects. This is basically due to the progress bars that are being used and that, for CI environments without proper ANSI support, is quite irrelevant.

It’s better to show it with the screenshot:


Now Infection does not output this information if --no-progress option is used or if CI is automatically detected:


For example, there is no need to add this option on Travis.

New Mutators

Starting from 0.13.0 Infection supports mutation of functions from 2 PHP extensions:

bcmath mutators

The aim of this set of mutators is to ensure project really needs this extension. If you are working with arbitrary precision arithmetic or with really big int numbers - your tests must know about that.

One of the examples of mutation produced by this mutator is:

- $bigIntInString = bcadd($a, b);
+ $bigIntInString = (string) ($a + $b);

Either kill it or don’t use bc* functions - they are used without a real reason.

See all bcmath mutators on the corresponded documentation page.

mbstring mutators

It is common to see people use multibyte string functions (like mb_strlen()) instead of their common analogs (like strlen()), while not writing any tests exploiting multibyte functionality.

In this situations mutators as simple as below could be of use:

- if (mb_strlen($str) < 10) {
+ if (strlen($str) < 10) {

See all mbstring mutators on the corresponded documentation page.

Array item removal mutator

Removes an item (or items) from the array, depending on Mutator settings.


- $keywords = ['select', 'from', 'where'];
+ $keywords = ['from', 'where'];

Configuration options:

For more information, see the corresponded documentation page

AssignCoalesce mutator

- $this->request->data['comments']['user_id'] ??= 'value';
+ $this->request->data['comments']['user_id'] = 'value';

See https://wiki.php.net/rfc/null_coalesce_equal_operator

@unwrap profile - added last mutators

We’ve added many new mutators that unwrap the function call

- $a = array_intersect_assoc(['A', 1, 'C'], ['D']);
+ $a = ['A', 1, 'C'];

New functions in 0.13.0 are:

All new ideas are tracked here: https://github.com/infection/infection/issues/514
See all existing @unwrap mutators on the corresponded documentation page.

There are also many bugfixes in 0.13.0, please upgrade!