-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a9b14b5
commit 02f9f90
Showing
6 changed files
with
2,020 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,5 @@ | |
/.idea | ||
/.php_cs.cache | ||
/vendor/ | ||
.phpunit.result.cache | ||
infection.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# 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. | ||
|
||
## 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: | ||
|
||
```php | ||
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 | ||
|
||
* 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 | ||
|
||
Please read documentation here: [infection.github.io](http://infection.github.io) | ||
|
||
Twitter: [@infection_php](http://twitter.com/infection_php) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.