Skip to the content
Know your tech before you buy it. Makers: get listed from $49/mo

Infection

infection.github.io

  • Free plan
  • macOS
  • Linux
  • Web

What Infection is

Infection is a free mutation-testing tool for PHP projects that checks whether tests detect changes to source code. It creates altered versions of code using predefined operators, runs tests that cover the changed lines, and records detected and surviving mutations, errors, and timeouts. Its Mutation Score Indicator reports the share of generated mutations caught by tests, alongside Mutation Code Coverage and Covered Code Mutation Score Indicator. Infection supports PHPUnit, PhpSpec, Codeception, and Testo, and runs from a project root as a CLI tool. Teams can parallelize runs, focus on changed lines or files, and configure minimum mutation scores to fail a build. Optional PHPStan and Mago integrations can help catch escaped mutants tied to type violations, dead code, and unreachable paths. It can publish reports and badges through Stryker Dashboard and emit GitHub annotations or GitLab Code Quality reports. Installation options include PHAR, Phive, Composer, Git, and Homebrew. A browser playground supports trials without local installation. Infection requires PHP 8.3 or newer and Xdebug, phpdbg, or pcov.

Who it suits

It suits PHP developers and teams who want to measure whether their tests catch code changes, including teams adding mutation-score gates to CI. The browser playground offers a way to try mutation testing without installing the command-line tools.

Good to know, and what to watch

  • Works with PHPUnit, PhpSpec, Codeception, and Testo
  • Can limit analysis to changed lines or files
  • Configurable mutation-score thresholds can fail builds
  • Provides a browser playground without local installation
  • Requires PHP 8.3 or newer
  • Needs Xdebug, phpdbg, or pcov
  • Parallel runs can misreport dependent or database-backed tests

The verdict

Infection provides several ways to focus mutation testing and surface results in development workflows. Its runtime requirements and warning about parallel tests are worth checking before adopting it.

What the maker publishes

Browser playground
The Infection Playground lets users write PHP code and tests in a browser and run mutation testing without installing Composer, Infection, or PHPUnit. source
Caveat
The command-line guide warns that parallel runs can produce false positives when tests depend on one another or use a database. source
Changed-code mode
The --git-diff-lines option mutates only touched lines, and --git-diff-filter can restrict mutation to changed files. source
CI reports
Infection can emit GitHub annotations and GitLab Code Quality reports, and can publish mutation badges and HTML reports through Stryker Dashboard. source
CI thresholds
The --min-msi and --min-covered-msi options can fail a build when configured mutation scores are not reached. source
CI thresholds
The --min-msi and --min-covered-msi options can fail a build when the configured mutation-score threshold is not met. source
Cloud reporting
Infection can send mutation badges and HTML reports to Stryker Dashboard using a project API key. source
Community support
The project links to Discord and GitHub Discussions for community help and states that it welcomes pull requests and issues. source
Distribution
The recommended PHAR distribution bundles PHPUnit, PhpSpec, Codeception and Testo, and the PHAR signature can be verified with the documented GPG key. source
How it works
It creates mutants using predefined mutation operators, runs tests covering changed lines, and records killed or escaped mutants, errors, and timeouts. source
Installation
The maker documents PHAR, Phive, Composer, Git, and Homebrew installation methods. source
License
The project is released under the BSD-3-Clause license. source
License
The project is released under the BSD-3-Clause License. source
Mutation metrics
Infection provides Mutation Score Indicator, Mutation Code Coverage and Covered Code Mutation Score Indicator metrics. source
Mutation score
It reports a Mutation Score Indicator (MSI) that measures the percentage of generated mutations detected by the tests. source
Mutators
The homepage describes more than 100 mutators grouped into profiles, plus custom mutator support. source
Mutators
The homepage describes more than 100 mutators, grouped into profiles, and support for custom mutators. source
Parallel execution
Tests for mutated code can run in parallel with the --threads option, including automatic CPU-core detection with --threads=max. source
Purpose
Infection mutates PHP source code and reports which changes a test suite fails to catch. source
Purpose
Infection mutates PHP source code and reports changes that a test suite fails to catch. source
Runtime requirements
The current documentation requires PHP 8.3 or newer and Xdebug, phpdbg or pcov. source
Runtime requirements
The current guide says Infection requires PHP 8.3 or later and Xdebug, phpdbg, or pcov installed. source
Security
The maker says its PHAR distribution is signed with a GPG key and documents how to verify the signature and fingerprint. source
Security policy
Only the latest Infection version is supported under its security policy, although older versions may be patched depending on vulnerability severity; vulnerabilities should be reported privately on GitHub. source

Checked against the maker's pages on 2 Oct 2026.