PHPackages                             gmazzap/andrew - 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. gmazzap/andrew

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

gmazzap/andrew
==============

Proxy objects to access (dynamic and static) private properties and methods.

2.1.0(9y ago)923.3k↓33.3%7MITPHPPHP &gt;=5.6

Since Jul 7Pushed 9y ago2 watchersCompare

[ Source](https://github.com/gmazzap/Andrew)[ Packagist](https://packagist.org/packages/gmazzap/andrew)[ Docs](https://github.com/Giuseppe-Mazzapica/Andrew)[ RSS](/packages/gmazzap-andrew/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (1)Versions (7)Used By (7)

Andrew
======

[](#andrew)

> Proxy objects to access (dynamic and static) private properties and methods.

---

[![travis-ci status](https://camo.githubusercontent.com/2506bb4ca0c3da919acf5ab42795c5e0b2c3fb2904982828e8308e1e43d9a474/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f676d617a7a61702f416e647265772e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/gmazzap/Andrew)[![codecov.io](https://camo.githubusercontent.com/cd952e63334f9907d2127a3eaf2c71894af8aba82cc3e5ed0eb38969ed66d313/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f676d617a7a61702f416e647265772e7376673f7374796c653d666c61742d737175617265)](http://codecov.io/github/gmazzap/Andrew?branch=master)[![license](https://camo.githubusercontent.com/59eab40c8c67bd2cdb09411576785dd668a95c9f9fa14fab2647505b13ccf84b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f676d617a7a61702f416e647265772e7376673f7374796c653d666c61742d737175617265)](http://opensource.org/licenses/MIT)

---

What
====

[](#what)

Andrew allow to access (read &amp; write) private properties and methods of any objects.

It provides 2 "proxy" objects, one for dynamic properties and methods, the other for static properties and method.

Proxy
=====

[](#proxy)

Let's assume following class

```
class Subject
{
  private $var = 'I am private';

  public function getVar() {
      return $this->var;
  }

  public function hasVar() {
      return isset($this->var);
  }

  private function testMe() {
      return 'I am private';
  }
}
```

With *Andrew* is possible to:

```
$subject = new Subject();

$proxy = new Andrew\Proxy($subject);

// get subject private var via proxy
echo $proxy->var; // 'I am private'

// set subject private var via proxy
$proxy->var = 'I WAS private';
echo $subject->getVar(); // 'I WAS private'

// check subject private var is set via proxy
isset($proxy->var); // true

// unset subject private var via proxy
unset($proxy->var);
$subject->hasVar(); // false

// call subject private method via proxy
echo $proxy->testMe() // 'I am private'
```

The `Subject` class example has public getter and isser for its private variable, that we added for test purposes, bu Andrew proxy is, of course, more useful when classes does not provide that possibility.

Static Proxy
============

[](#static-proxy)

Let's assume following class

```
class Subject
{
    private static $var = 'I am private static';

    public static function getVar() {
        return self::$var;
    }

    private static function testMe() {
        return 'I am private static';
    }
}
```

With *Andrew* is possible to:

```
$proxy = new Andrew\StaticProxy(Subject::class); // we pass class name, not object

// getter
echo $proxy->var; // 'I am private static'

// setter
$proxy->var = 'I WAS private static';
echo Subject::getVar(); // 'I WAS private static'

// isser
isset($proxy->var); // true

// caller
echo $proxy->testMe() // 'I am private static'
```

Note that `StaticProxy` has **not** unsetter, because PHP [does not allow to unset static variables](http://3v4l.org/91GTk).

If you try to unset anything on a `StaticProxy` object, *Andrew* will throw an Exception.

Exceptions
==========

[](#exceptions)

There are several exceptions thrown by *Andrew*. All of them are in the namespace `Andrew\Exception`.

They are:

- `ArgumentException` thrown when an invalid type of argument is used. E.g. when a method expects a string and receives a number or anything else.
- `ClassException` thrown when a method expects a class but receives a string that is not a valid class name.
- `PropertyException` when trying to access a non-existent variable, or either when trying to access a static variable using `Proxy`or a non-static property using `StaticProxy`.
- `MethodException` when trying to access a non-existent method, or either when trying to access a static method using `Proxy`or a non-static method using `StaticProxy`.
- `RuntimeException` when trying to unset a static variable

Installation
============

[](#installation)

Install via Composer, package name is `"gmazzap/andrew"` and it is available on [Packagist](https://packagist.org/packages/gmazzap/andrew).

Should I use this in production?
================================

[](#should-i-use-this-in-production)

No. But may be quite useful in unit tests.

Requirements
============

[](#requirements)

*Andrew* has no dependencies. Requires PHP 5.6+, works with PHP 7 and 7.1.

License
=======

[](#license)

MIT

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

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

Total

5

Last Release

3349d ago

Major Versions

1.1.0 → 2.0.02017-03-12

PHP version history (2 changes)1.0.0PHP &gt;=5.4

2.0.0PHP &gt;=5.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2208282?v=4)[Giuseppe Mazzapica](/maintainers/gmazzap)[@gmazzap](https://github.com/gmazzap)

---

Top Contributors

[![gmazzap](https://avatars.githubusercontent.com/u/2208282?v=4)](https://github.com/gmazzap "gmazzap (30 commits)")

---

Tags

unit-testsproxy objects

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/gmazzap-andrew/health.svg)

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

###  Alternatives

[scws/pscws4

PSCWS 是英文 PHP Simple Chinese Words Segmentation 的头字母缩写，它是 SCWS 项目的前身。

1213.2k1](/packages/scws-pscws4)

PHPackages © 2026

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