PHPackages                             icewind/patcher - 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. icewind/patcher

AbandonedArchivedLibrary

icewind/patcher
===============

Replace build in php functions

v0.4.0(10y ago)034MITPHP

Since Sep 28Pushed 10y agoCompare

[ Source](https://github.com/icewind1991/patcher)[ Packagist](https://packagist.org/packages/icewind/patcher)[ RSS](/packages/icewind-patcher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

Patcher
=======

[](#patcher)

[![Build Status](https://camo.githubusercontent.com/ff6a044edf0516a9d645b34a9a77a2ffd125999549d12e6d489d0023ccb07e7e/68747470733a2f2f7472617669732d63692e6f72672f69636577696e64313939312f706174636865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/icewind1991/patcher)[![Code Coverage](https://camo.githubusercontent.com/28d7b2f59dd94fdf9a07d1dbe72ad863d0fb33518e33b3c81c23f3482a8291e5/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69636577696e64313939312f706174636865722f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/icewind1991/patcher/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/7acff092300dcc6d77f354e778a5a231cab97257c6577b027a80cd66c2d80a9b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f69636577696e64313939312f706174636865722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/icewind1991/patcher/?branch=master)

Replace build in php functions

```
composer require icewind/patcher

```

Usage
-----

[](#usage)

### Overwriting a method

[](#overwriting-a-method)

```
use Icewind\Patcher\Patcher;

$patcher = new Patcher();
$patcher->patchMethod('time', function () {
    return 100;
});
$patcher->whiteListDirectory(__DIR__ . '/src');
$patcher->autoPatch();

include 'src/....';
```

### Using the original method

[](#using-the-original-method)

```
use Icewind\Patcher\Patcher;

$patcher = new Patcher();
$patcher->patchMethod('time', function ($method, $arguments, $original) {
    $time = $original();
    error_log("Time: $time");
    return $time;
});
$patcher->whiteListDirectory(__DIR__ . '/src');
$patcher->autoPatch();

include 'src/....';
```

### Overwriting a class

[](#overwriting-a-class)

```
use Icewind\Patcher\Patcher;

class DummyDateTime extends DateTime {
	public function __construct() {
		parent::__construct("1970-01-01 00:00:00 UTC");
	}
}

$patcher = new Patcher();
$patcher->patchClass('\DateTime', '\DummyDateTime');
$patcher->whiteListDirectory(__DIR__ . '/src');
$patcher->autoPatch();

include 'src/....';
```

API
---

[](#api)

- `patchMethod(string $method, callable $handler)`: Set the handler for a method
- The handler will be called with the following three arguments
- `string $method` the name of the method being called
- `array $arguments` the arguments the method was called with
- `callable $original` a closure which will call the overwriten method with the correct arguments and return the result
- `patchClass(string $method, string $replacement)`: Overwrite a class with a different one
    - Note, at the moment this only works with classes in the global namespace
- `whiteListDirectory(string $path)`: Add a directory to the white list for the auto patcher
- `blackListDirectory(string $path)`: Add a directory to the black list for the auto patcher
- `autoPatch()`: Enable auto patching for all files included from this point
- Automatically apply the patch methods for any namespace defined
- Will only be applied for files within a whitelisted directory

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~8 days

Total

4

Last Release

3859d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ea4722a1296fa93edb98eae91349659927af69f7711cf35693be2b4c28ea618?d=identicon)[icewind1991](/maintainers/icewind1991)

---

Top Contributors

[![icewind1991](https://avatars.githubusercontent.com/u/1283854?v=4)](https://github.com/icewind1991 "icewind1991 (17 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/icewind-patcher/health.svg)

```
[![Health](https://phpackages.com/badges/icewind-patcher/health.svg)](https://phpackages.com/packages/icewind-patcher)
```

PHPackages © 2026

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