PHPackages                             infection/include-interceptor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. infection/include-interceptor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

infection/include-interceptor
=============================

Stream Wrapper: Include Interceptor. Allows to replace included (autoloaded) file with another one.

1.0.0(2y ago)3126.0M↓27.3%4[3 issues](https://github.com/infection/include-interceptor/issues)[1 PRs](https://github.com/infection/include-interceptor/pulls)5BSD-3-ClausePHPCI failing

Since Jan 17Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/infection/include-interceptor)[ Packagist](https://packagist.org/packages/infection/include-interceptor)[ GitHub Sponsors](https://github.com/infection)[ Fund](https://opencollective.com/infection)[ RSS](/packages/infection-include-interceptor/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (6)Dependencies (14)Versions (7)Used By (5)

[![Build Status](https://camo.githubusercontent.com/7a5ad59fb6e72dad15418bc91deee84ea34747dff64762bdaeefe906e12df0ca/68747470733a2f2f7472617669732d63692e6f72672f696e66656374696f6e2f696e636c7564652d696e746572636570746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/infection/include-interceptor)[![Coverage Status](https://camo.githubusercontent.com/d2f961a84b4775f69131695d69485d36517a6498067e4bcc8792b856c536315b/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f696e66656374696f6e2f696e636c7564652d696e746572636570746f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/infection/include-interceptor?branch=master)

Infection - Include Interceptor Stream Wrapper
==============================================

[](#infection---include-interceptor-stream-wrapper)

It's a [Stream Wrapper](https://www.php.net/manual/en/book.stream.php) that wraps a [`file://`](https://www.php.net/manual/en/wrappers.file.php) protocol and allows overriding content of any (auto) loaded file, including files autoloaded by Composer package manager.

Installation
------------

[](#installation)

```
composer require infection/include-interceptor
```

How it works
------------

[](#how-it-works)

If you want to replace the content of the file whenever it's loaded (by executing `include '/path/to/file.php`, by calling `file_get_contents('/path/to/file.php')`, etc.), you need to register `IncludeInterceptor` *before* loading original file:

```
use Infection\StreamWrapper\IncludeInterceptor;

IncludeInterceptor::intercept('/path/to/original_file.php', '/path/to/replacement_file.php');
IncludeInterceptor::enable();
```

After enabling `IncludeInterceptor`, content of the `replacement_file.php` will be loaded instead of content of the `original_file.php`.

Use cases
---------

[](#use-cases)

- This Stream Wrapper is used to replace the original file with the Mutant in [Infection](http://infection.github.io) Mutation Testing Framework
- The same approach is used in the [`dg/bypass-finals`](https://github.com/dg/bypass-finals/) package that allows to mock `final` classes, by overriding original content and removing `final` keyword in runtime

Infection - Mutation Testing Framework
--------------------------------------

[](#infection---mutation-testing-framework)

Please read documentation here: [infection.github.io](http://infection.github.io)

Twitter: [@infection\_php](http://twitter.com/infection_php)

###  Health Score

54

—

FairBetter than 97% of packages

Maintenance59

Moderate activity, may be stable

Popularity59

Moderate usage in the ecosystem

Community24

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 54.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~313 days

Recently: every ~389 days

Total

6

Last Release

767d ago

Major Versions

0.2.5 → 1.0.02024-05-03

### Community

Maintainers

![](https://www.gravatar.com/avatar/a0196ce472ed16a55b72aa7f9f9956bc6e68fa519abf975caffc9fcb5fa320df?d=identicon)[borN\_free](/maintainers/borN_free)

---

Top Contributors

[![maks-rafalko](https://avatars.githubusercontent.com/u/3725595?v=4)](https://github.com/maks-rafalko "maks-rafalko (17 commits)")[![sanmai](https://avatars.githubusercontent.com/u/139488?v=4)](https://github.com/sanmai "sanmai (10 commits)")[![BackEndTea](https://avatars.githubusercontent.com/u/14289961?v=4)](https://github.com/BackEndTea "BackEndTea (2 commits)")[![DanielSiepmann](https://avatars.githubusercontent.com/u/354250?v=4)](https://github.com/DanielSiepmann "DanielSiepmann (1 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/infection-include-interceptor/health.svg)

```
[![Health](https://phpackages.com/badges/infection-include-interceptor/health.svg)](https://phpackages.com/packages/infection-include-interceptor)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
