PHPackages                             vedavith/liberator-fork - 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. vedavith/liberator-fork

ActiveLibrary

vedavith/liberator-fork
=======================

A proxy for circumventing PHP access modifier restrictions.

v4.2.0(3mo ago)12.0kMITPHPPHP &gt;=8.2CI passing

Since Feb 9Pushed 3mo agoCompare

[ Source](https://github.com/vedavith/liberator-fork)[ Packagist](https://packagist.org/packages/vedavith/liberator-fork)[ Docs](https://github.com/vedavith/liberator-fork)[ RSS](/packages/vedavith-liberator-fork/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (5)Versions (5)Used By (0)

Liberator
=========

[](#liberator)

*A proxy for circumventing PHP access modifier restrictions.*

> - This is a maintained fork of the unmaintained `eloquent/liberator`. Package name is `vedavith/liberator-fork` and it targets PHP 8.2+ with PHPUnit 11/12 for development.
> - This is a maintained fork of \[eloquent/liberator\] originally created by Erin Millard.

Installation and documentation
------------------------------

[](#installation-and-documentation)

- Available as [Composer](http://getcomposer.org/) package [vedavith/liberator-fork](https://packagist.org/packages/vedavith/liberator-fork): (maintained fork of `eloquent/liberator`).
- Requires PHP 8.2 or later.

```
  composer require vedavith/liberator-fork

```

What is Liberator?
------------------

[](#what-is-liberator)

*Liberator* allows access to **protected** and **private** methods and properties of objects as if they were marked **public**. It can do so for both objects and classes (i.e. static methods and properties).

*Liberator*'s primary use is as a testing tool, allowing direct access to methods that would otherwise require complicated test harnesses or mocking to test.

Usage
-----

[](#usage)

### For objects

[](#for-objects)

Take the following class:

```
class SeriousBusiness
{
    private function foo($adjective)
    {
        return 'foo is ' . $adjective;
    }

    private $bar = 'mind';
}
```

Normally there is no way to call `foo()` or access `$bar` from outside the `SeriousBusiness` class, but *Liberator* allows this to be achieved:

```
use Eloquent\Liberator\Liberator;

$object = new SeriousBusiness;
$liberator = Liberator::liberate($object);

echo $liberator->foo('not so private...'); // outputs 'foo is not so private...'
echo $liberator->bar . ' = blown';         // outputs 'mind = blown'
```

### For classes

[](#for-classes)

The same concept applies for static methods and properties:

```
class SeriousBusiness
{
    static private function baz($adjective)
    {
        return 'baz is ' . $adjective;
    }

    static private $qux = 'mind';
}
```

To access these, a *class liberator* must be used instead of an *object liberator*, but they operate in a similar manner:

```
use Eloquent\Liberator\Liberator;

$liberator = Liberator::liberateClass('SeriousBusiness');

echo $liberator->baz('not so private...'); // outputs 'baz is not so private...'
echo $liberator->qux . ' = blown';         // outputs 'mind = blown'
```

Alternatively, *Liberator* can generate a class that can be used statically:

```
use Eloquent\Liberator\Liberator;

$liberatorClass = Liberator::liberateClassStatic('SeriousBusiness');

echo $liberatorClass::baz('not so private...');      // outputs 'baz is not so private...'
echo $liberatorClass::liberator()->qux . ' = blown'; // outputs 'mind = blown'
```

Unfortunately, there is (currently) no \_\_getStatic() or \_\_setStatic() in PHP, so accessing static properties in this way is a not as elegant as it could be.

Applications for Liberator
--------------------------

[](#applications-for-liberator)

- Writing [white-box](http://en.wikipedia.org/wiki/White-box_testing) style unit tests (testing protected/private methods).
- Modifying behavior of poorly designed third-party libraries.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance81

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% 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 ~0 days

Total

3

Last Release

99d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/ee4ad7e16481b8e1396978ef1416fe323cae31434cbc844b011c9850c5d30ab4?d=identicon)[vedavith](/maintainers/vedavith)

---

Top Contributors

[![ezzatron](https://avatars.githubusercontent.com/u/100152?v=4)](https://github.com/ezzatron "ezzatron (21 commits)")[![vedavith](https://avatars.githubusercontent.com/u/18259805?v=4)](https://github.com/vedavith "vedavith (9 commits)")

---

Tags

proxyreflectionobjectaccessmodifierprivateprotected

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/vedavith-liberator-fork/health.svg)

```
[![Health](https://phpackages.com/badges/vedavith-liberator-fork/health.svg)](https://phpackages.com/packages/vedavith-liberator-fork)
```

###  Alternatives

[symfony/property-access

Provides functions to read and write from/to an object or array using a simple string notation

2.8k295.3M2.5k](/packages/symfony-property-access)[fritzmg/contao-file-access

Contao extension that allows file access restrictions for frontend users.

105.1k](/packages/fritzmg-contao-file-access)

PHPackages © 2026

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