PHPackages                             hakito/publisher - 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. hakito/publisher

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

hakito/publisher
================

Proxy for accessing protected/private class members.

v1.3(5y ago)01923MITPHPPHP &gt;=5.4

Since Mar 1Pushed 5y ago1 watchersCompare

[ Source](https://github.com/hakito/PhpPublisher)[ Packagist](https://packagist.org/packages/hakito/publisher)[ Docs](https://github.com/hakito/PhpPublisher)[ RSS](/packages/hakito-publisher/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (4)Used By (3)

PhpPublisher
============

[](#phppublisher)

[![Build Status](https://camo.githubusercontent.com/d44f01e4fa655850516e37b4d9223754b8a574a88333db4b3931462c6e8da737/68747470733a2f2f7472617669732d63692e636f6d2f68616b69746f2f5068705075626c69736865722e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/hakito/PhpPublisher)[![Coverage Status](https://camo.githubusercontent.com/52a388acfcd74f0cf163fee9b7984bf4e3653e437e582440d1a60e195d6c8118/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f68616b69746f2f5068705075626c69736865722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/hakito/PhpPublisher?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/160fbcb0babc5a4eb19e69fea6b7174f6cd96eae4d8f72f5ab7f2d0b2f0690a3/68747470733a2f2f706f7365722e707567782e6f72672f68616b69746f2f7075626c69736865722f762f737461626c65)](https://packagist.org/packages/hakito/publisher)[![Total Downloads](https://camo.githubusercontent.com/cab4f86b9fdd4e6f02879052d8412fb17a1e7a058aae1055dfbf80dcd7236204/68747470733a2f2f706f7365722e707567782e6f72672f68616b69746f2f7075626c69736865722f646f776e6c6f616473)](https://packagist.org/packages/hakito/publisher)[![Latest Unstable Version](https://camo.githubusercontent.com/c1e2a5ca475df422b30e4f59c68b1a51572189b7856773d9c3ac056ec5db4305/68747470733a2f2f706f7365722e707567782e6f72672f68616b69746f2f7075626c69736865722f762f756e737461626c65)](https://packagist.org/packages/hakito/publisher)[![License](https://camo.githubusercontent.com/1a415b9f63948c81071b1c9443475c4c6efb794a07f15b0e8ff8df2d2a78adfa/68747470733a2f2f706f7365722e707567782e6f72672f68616b69746f2f7075626c69736865722f6c6963656e7365)](https://packagist.org/packages/hakito/publisher)

Simple proxy for accessing protected/private class members.

It's intention is to give unit tests access to private members without reinventing the wheel.

This helper uses closures to access private members of a class instead of reflection.

Installation
------------

[](#installation)

```
composer require hakito/publisher
```

Usage
-----

[](#usage)

Guess you have a class with private members:

```
class Target
{
    private $foo = 'secret';
    private function bar($arg) { return $arg . 'Bar'; }

    private static $sFoo = 'staticSecret';
}
```

Create the proxy to access these members:

```
$target = new Target();
$published = new hakito\Publisher\Published($target);

// Get private property
$property = $published->foo;
// $property = 'secret';

// Set private property
$published->foo = 'outsider';
// $target->foo = 'outsider';

// call private method
$name = $published->bar('Saloon');
// $name = 'SaloonBar';

// Optional you can provide a base class in the constructor
class Derived extends Target {
    private $foo = 'derived';
}

$derived = new Derived();
$published = new hakito\Publisher\Published($derived, Target::class);
$property = $published->foo; // Gets property from Target
// $property = 'secret';
```

### Accessing static members

[](#accessing-static-members)

If you want to access static fields or methods you have to use the class StaticPublished

```
$published = new StaticPublished(Target::class);

$property = $published->sFoo;
// $property = 'staticSecret'
```

Setting fields and calling methods works the same as for instances.

Limitations
-----------

[](#limitations)

### The published method call cannot set a reference argument.

[](#the-published-method-call-cannot-set-a-reference-argument)

```
class Target
{
    private function methodWithReferenceArgument(&$arg) { $arg = 'hi'; }
}

$target = new Target();
$published = new hakito\Publisher\Published($target);
$val = 'initial';
$published->methodWithReferenceArgument($val);
// $val is still 'initial'
```

### The return value from method call cannot be a reference

[](#the-return-value-from-method-call-cannot-be-a-reference)

```
class Target
{
    private $_member = [];
    private function &methodWithReferenceReturnValue($arg) { return $this->_member; }
}

$target = new Target();
$published = new hakito\Publisher\Published($target);
$val = 'initial';
$published->methodWithReferenceReturnValue($val)['new'] = 'value';
// Target::_member is still []
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity53

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

Total

3

Last Release

2158d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/320853?v=4)[Gerd Katzenbeisser](/maintainers/hakito)[@hakito](https://github.com/hakito)

---

Top Contributors

[![hakito](https://avatars.githubusercontent.com/u/320853?v=4)](https://github.com/hakito "hakito (11 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/hakito-publisher/health.svg)

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

PHPackages © 2026

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