PHPackages                             camspiers/closureaccess - 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. camspiers/closureaccess

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

camspiers/closureaccess
=======================

Brings JavaScript-like functionality to your objects

0.3.1(11y ago)119PHP

Since Feb 24Pushed 11y ago1 watchersCompare

[ Source](https://github.com/camspiers/closureaccess)[ Packagist](https://packagist.org/packages/camspiers/closureaccess)[ RSS](/packages/camspiers-closureaccess/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (2)Versions (6)Used By (0)

Closure Access
==============

[](#closure-access)

The closure access trait brings JavaScript-like functionality to your objects in the following ways:

- Public methods on objects can be accessed as properties e.g. $obj-&gt;methodName
- Closures added to objects can be executed like public methods e.g. $obj-&gt;closureProp()

No claims are made as to whether you should use this library, it is provided more as a proof of concept.

Installation (with composer)
----------------------------

[](#installation-with-composer)

```
composer require camspiers/closureaccess:dev-master

```

Performance
-----------

[](#performance)

- Accessing public methods as properties e.g. $obj-&gt;methodName (return Closure)
- `~2.1x` slower
- Closures added to objects can be executed like public methods e.g. $obj-&gt;closureProp()
- `~3.1x` slower

Usage
-----

[](#usage)

```
class A {
    use Camspiers\ClosureAccess;
    public function hello()
    {
        return "Hello";
    }
}

function run($fn) {
    return $fn();
}

$a = new A;

// an example of accessing a public method via properties and passing it around
echo run($a->hello), ', World';

// an example of executing a closure property as a method
$a->world = function () {
    return "World";
};

echo 'Hello, ', $a->world();
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity57

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

Total

5

Last Release

4364d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/91d02ba78b01d0432821f6195f11d6b95aa8da31f02f8aaea7a2e7215662061a?d=identicon)[camspiers](/maintainers/camspiers)

---

Top Contributors

[![camspiers](https://avatars.githubusercontent.com/u/51294?v=4)](https://github.com/camspiers "camspiers (12 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/camspiers-closureaccess/health.svg)

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

###  Alternatives

[aimeos/macro

Customize classes using closures

2.3k131.7k5](/packages/aimeos-macro)[nodejs-php-fallback/stylus

PHP wrapper to execute stylus node package or fallback to a PHP alternative

11135.5k4](/packages/nodejs-php-fallback-stylus)[cityofzion/neo-php

NEO blockchain implementation for PHP

152.0k](/packages/cityofzion-neo-php)[miraheze/rotten-links

A MediaWiki extension to show the state of all external links on the wiki.

101.5k](/packages/miraheze-rotten-links)

PHPackages © 2026

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