PHPackages                             petrp/access - 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. petrp/access

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

petrp/access
============

Access - Tool for access to private and protected members of object. It's handy for unit tests.

v0.3.0(3y ago)63.9k↓100%11BSD-3-ClausePHPPHP &gt;=5.2.0

Since Aug 19Pushed 3y ago1 watchersCompare

[ Source](https://github.com/PetrP/Access)[ Packagist](https://packagist.org/packages/petrp/access)[ Docs](https://github.com/PetrP/Access)[ RSS](/packages/petrp-access/feed)WikiDiscussions master Synced 2mo ago

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

Access
======

[](#access)

Tool for access to private and protected members of object. It's handy for unit tests.

Property
--------

[](#property)

```
class Foo
{
	private $foo;
}

$a = Access(new Foo, '$foo');

$a->set(3);
assert($a->get() === 3);
```

Method
------

[](#method)

```
class Foo
{
	private function bar()
	{
		return 4;
	}
}

$a = Access(new Foo, 'bar');

assert($a->call() === 4);
```

Whole class
-----------

[](#whole-class)

```
class Foo
{
	private $foo;

	private function bar($plus)
	{
		return $this->foo + $plus;
	}
}

$a = Access(new Foo);

$a->foo = 10;
assert($a->foo === 10);
assert($a->bar(1) === 11);
```

Chaining objects and arrays
---------------------------

[](#chaining-objects-and-arrays)

```
class Foo
{
	private $foo;

	public function __construct()
	{
		$this->foo = ['arrayKey' => new Bar];
	}
}
class Bar
{
	private $bar;
}

$a = AccessProxy(new Foo);

$a->foo['arrayKey']->bar = 100;
assert($a->foo['arrayKey']->bar === 100);

assert($a->foo instanceof AccessProxy);
assert(is_array($a->foo->getInstance()));
assert($a->foo['arrayKey'] instanceof AccessProxy);
assert($a->foo['arrayKey']->getInstance() instanceof Bar);
```

Requirements
------------

[](#requirements)

Library has no external dependencies.

Up to PHP &lt;= 8.2 tested. Fully works with PHP &gt;= 5.3.2. PHP &gt;= 5.2.0 is supported partially (see below).

AccessMethod require PHP 5.3.2 or later. AccessProperty require PHP 5.3.0 or later.

PHP &gt;= 5.2.0 AND &lt; 5.3.2 not supported:

- Final classes.
- Private methods.
- Read private static property.
- Write private property.
- No limitation when extension [runkit](https://pecl.php.net/package/runkit) or [classkit](https://pecl.php.net/package/classkit) is provided.

Instalations
------------

[](#instalations)

### GitHub

[](#github)

Each version is tagged and available on [download page](https://github.com/PetrP/Access/tags).

```
require_once __DIR__ . '/.../Access/src/Init.php';
```

### Composer &amp; Packagist

[](#composer--packagist)

Access is available on [Packagist](http://packagist.org/packages/PetrP/Access), where you can get it via [Composer](http://getcomposer.org).

```
composer require petrp/access
```

```
require_once __DIR__ . '/vendor/autoload.php';
```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98% 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 ~1276 days

Total

4

Last Release

1187d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/962a151b42c01e9ddaf44c39218291fca607188cb099d3a236c1d2236be78643?d=identicon)[PetrP](/maintainers/PetrP)

---

Top Contributors

[![PetrP](https://avatars.githubusercontent.com/u/133768?v=4)](https://github.com/PetrP "PetrP (50 commits)")[![JanTvrdik](https://avatars.githubusercontent.com/u/175109?v=4)](https://github.com/JanTvrdik "JanTvrdik (1 commits)")

---

Tags

testingdev

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/petrp-access/health.svg)

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

###  Alternatives

[orchestra/testbench

Laravel Testing Helper for Packages Development

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

Testing Helper for Laravel Development

27043.7M310](/packages/orchestra-testbench-core)[orchestra/workbench

Workbench Companion for Laravel Packages Development

8017.0M43](/packages/orchestra-workbench)[donatj/mock-webserver

Simple mock web server for unit testing

1382.5M80](/packages/donatj-mock-webserver)[guanguans/laravel-soar

SQL optimizer and rewriter for laravel. - laravel 的 SQL 优化器和重写器。

2227.8k](/packages/guanguans-laravel-soar)[pierstoval/smoke-testing

Smoke testing automator for Symfony applications

4032.6k](/packages/pierstoval-smoke-testing)

PHPackages © 2026

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