Library / SDK
infection/infection avatar
infection/infection

Infection: mutation testing that finds the assertions that never fail

PHP Mutation Testing library

2,276 stars199 forksPHPBSD-3-Clause

At a glance

What is it?
Infection is a PHP mutation testing framework. It introduces small changes to code and runs tests against them to reveal mutations the suite does not detect.
Who is it for?
Infection can complement coverage reports by exposing changes that tests do not detect. Review surviving mutants individually: some reveal missing tests, while equivalent or irrelevant mutations may require judgment.
Can I use it commercially?
Yes. BSD-3-Clause is a permissive licence: you can use, modify and sell software built on it, as long as you keep its copyright and licence notices.
Is it still maintained?
Yes. The repository received new commits within the last day.
What is it written in?
Mainly PHP, according to GitHub's language statistics.

Answers come from the project's GitHub data, last synced on November 25, 2026, and from our analysis. They are not legal advice.

From daily snapshots

Star history

  • infection/infection2,276 ★ · +22
Star history
Repository2026-10-072026-11-25
infection/infection2.3k2.3k

22 Stars in the last 49 days, measured from the daily GitHub snapshot. Compare with other projects

Editorial analysis

What mutation testing adds to coverage

Coverage records which code executes; mutation testing asks whether tests detect selected changes to that code. Infection creates mutants and runs relevant tests to see whether they are killed or survive. A surviving mutant can point to a missing test or assertion, but it can also be equivalent for the program’s intended behavior. Review the mutation and its context before changing the suite. Mutation score summarizes results and should be read alongside the underlying mutants and any excluded cases.

Installation and compatibility

The official installation guide offers a signed PHAR, Phive, Composer, Git and Homebrew. The PHAR bundles the officially supported test frameworks; follow the guide to verify its signature when downloading it.

The guide lists Xdebug, phpdbg or pcov as coverage options, rather than requiring Xdebug alone. PHP compatibility depends on the Infection version: consult the current compatibility table and the selected release before installation. Older Infection versions can support older PHP versions.

Using Infection in a project

Install a compatible release using the project guide, run your normal test suite successfully, and configure Infection for the source and test framework you want to examine. Begin with a small directory or change set, inspect the surviving mutants, and add or improve tests where the mutation exposes a meaningful gap.

Mutation runs can be expensive because they execute tests repeatedly. Measure the cost on your own project, then decide whether to run a scoped check on pull requests and a broader run separately. Consult the current configuration and CI documentation for supported options.

Versions and maintenance

Infection is developed in a public repository under the BSD-3-Clause license. Its releases and compatibility requirements change over time; consult the release notes and installation guide before upgrading. Pin a version in automated workflows and test the upgrade against your PHP runtime, coverage driver and test framework.

Lineage, sponsors and the playground

The README's credits section is short and explains the project's design heritage. Infection is described as highly inspired by Humbug, a mutation testing library by Pádraic Brady, and the README notes that Humbug has since been discontinued in favour of Infection. So this is a successor rather than an original entry, and the credit is explicit about it.

The sponsor list mixes companies of quite different kinds. TestMuAI appears as a company sponsor alongside individual accounts, Enrise is listed as a company, and JetBrains is credited specifically with free licenses for core developers, which for a PHP project means PHPStorm. Sentry and Tideways are sponsors too, and both are error monitoring services, which is a reasonable fit for a tool that often runs in the same pipeline as test and monitoring infrastructure.

Two links are worth trying before installing anything. There is a Playground at infection-php.dev described as a way to try the tool right in the browser, which removes the setup cost of evaluating a mutation testing framework entirely. And there is an MSI badge in the README that pulls from the Stryker mutator badge service, so the project's own mutation score is tracked the same way other projects track build status.

Community links are on Twitter and Mastodon under the same handle, `@infection_php`, plus a Discord server. The README is otherwise a pointer document: it says to read the documentation at infection.github.io and links a contribution guide in `.github/CONTRIBUTING.md`. Configuration options, the list of mutators and the threshold settings live in that documentation, not in the repository.

Editorial conclusion

Infection can complement coverage reports by exposing changes that tests do not detect. Review surviving mutants individually: some reveal missing tests, while equivalent or irrelevant mutations may require judgment. Start with a limited scope, choose an Infection version compatible with your PHP version, and measure runtime before adding it to CI.

Frequently asked questions

What does Infection do differently from running a code coverage report?

Coverage reports execution; mutation testing changes code and checks whether tests detect the change. A surviving mutant is worth investigating, but it does not prove that no assertion checks the line: the change may be equivalent or outside the tested cases.

What PHP version does Infection require?

Requirements depend on the Infection release. The installation guide includes a compatibility table for PHP versions and older Infection releases; check it along with the release requirements for the version you install.

How is Infection distributed?

The official guide documents a signed PHAR, Phive, Composer, Git and Homebrew installation routes. The PHAR bundles the officially supported test frameworks.

What is the relationship between Infection and Humbug?

Infection replaces it. The README states the project is highly inspired by Humbug, a mutation testing library by Pádraic Brady, and that Humbug has been discontinued in favour of Infection. The Box PHAR tooling used to build Infection comes from the same Humbug project.

How do I try Infection without installing it?

The project links an online playground at infection-php.dev for trying mutation testing in a browser. Check the current playground for available versions and limits.

Official sources

  1. infection/infection on GitHub
  2. License: BSD-3-Clause
  3. Project website
  4. README
  5. Releases

Was this useful?