PHPackages                             kidfund/monkey-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. [Testing &amp; Quality](/categories/testing)
4. /
5. kidfund/monkey-patcher

ActiveLibrary[Testing &amp; Quality](/categories/testing)

kidfund/monkey-patcher
======================

Get tricky with php objects in test

1.0.1(7y ago)02.0k2[1 issues](https://github.com/Kidfund/MonkeyPatcher/issues)1MITPHPPHP ~7.0CI failing

Since Dec 6Pushed 6y ago1 watchersCompare

[ Source](https://github.com/Kidfund/MonkeyPatcher)[ Packagist](https://packagist.org/packages/kidfund/monkey-patcher)[ Docs](https://github.com/Kidfund/MonkeyPatcher)[ RSS](/packages/kidfund-monkey-patcher/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (3)Dependencies (1)Versions (8)Used By (1)

MonkeyPatcher
=============

[](#monkeypatcher)

[![Latest Version on Packagist](https://camo.githubusercontent.com/95f5d2b639a73294a9875b87e5062b2458588daeffb167684ba11244417f31a2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6b696466756e642f6d6f6e6b65792d706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kidfund/monkey-patcher)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/8032f82df0e188e695856bb34262a804e33af3a3b7d9f9240d6fd35dc0992b01/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f4b696466756e642f4d6f6e6b6579506174636865722f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/Kidfund/MonkeyPatcher)[![StyleCI](https://camo.githubusercontent.com/bcc6f23e10e2514f3f8719cb0caca2bfbd3fef326d2ac39efcade74effd509f6/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3135373931313133312f736869656c643f6272616e63683d6d6173746572)](https://github.styleci.io/repos/157911131)[![Total Downloads](https://camo.githubusercontent.com/b578330e6e4964910b823ea0c55eaf602acd2d92357e92f7a11cf319997d41db/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6b696466756e642f6d6f6e6b65792d706174636865722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/kidfund/monkey-patcher)

Access private functions and properties of PHP classes. Primarily used to muck with things under test.

- [MonkeyPatcher](#monkeypatcher)
- [Install](#install)
- [Usage](#usage)
    - [Setup](#setup)
    - [Access a private function](#access-a-private-function)
    - [Set a private property](#set-a-private-property)
    - [Get a private property](#get-a-private-property)
- [Testing](#testing)
- [Contributing](#contributing)
- [Credits](#credits)
- [License](#license)

Install
=======

[](#install)

Via Composer

```
$ composer require kidfund/monkey-patcher
```

Usage
=====

[](#usage)

*Note: If you are using this, you may have a broken pattern somewhere. Either in your main code or in test-land. But, sometimes you need it!*

Setup
-----

[](#setup)

Add the trait to your test

```
class MonkeyPatcherUnitTest extends PHPUnit_Framework_TestCase
{
    use MonkeyPatcher;
```

Access a private function
-------------------------

[](#access-a-private-function)

```
$this->invokeMethod($object, 'do', ['something']);
```

Set a private property
----------------------

[](#set-a-private-property)

```
$this->setProperty($object, 'msg', 'hello');
```

Get a private property
----------------------

[](#get-a-private-property)

```
$this->getProperty($object, 'msg');
```

Testing
=======

[](#testing)

```
$ ./vendor/bin/phpunit
```

Contributing
============

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Credits
=======

[](#credits)

- [@timborder](https://github.com/timbroder)

License
=======

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 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 ~3 days

Total

4

Last Release

2709d ago

Major Versions

0.9.1 → 1.0.02018-12-14

PHP version history (2 changes)0.9.0PHP ~5.5|~7.0

1.0.0PHP ~7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/492d66f0a40a30e71ea2dd714818002f6fafca3c2c243dd318aa9684ff982182?d=identicon)[timbroder](/maintainers/timbroder)

---

Top Contributors

[![timbroder](https://avatars.githubusercontent.com/u/121503?v=4)](https://github.com/timbroder "timbroder (1 commits)")

---

Tags

kidfundmonkey-patcher

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpspec/prophecy

Highly opinionated mocking framework for PHP 5.3+

8.5k551.7M682](/packages/phpspec-prophecy)[vimeo/psalm

A static analysis tool for finding errors in PHP applications

5.8k77.5M6.7k](/packages/vimeo-psalm)[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[beberlei/assert

Thin assertion library for input validation in business models.

2.4k96.9M570](/packages/beberlei-assert)[mikey179/vfsstream

Virtual file system to mock the real file system in unit tests.

1.4k108.0M2.7k](/packages/mikey179-vfsstream)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)

PHPackages © 2026

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