PHPackages                             antoksa/callable-that-proxy - 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. antoksa/callable-that-proxy

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

antoksa/callable-that-proxy
===========================

Lightweight proxy to create a callable from a 'dynamic' object during runtime

v2.0.0(1y ago)02MITPHPPHP ^8.0

Since Feb 13Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Anton5360/callable-that-proxy)[ Packagist](https://packagist.org/packages/antoksa/callable-that-proxy)[ Docs](https://github.com/Anton5360/callable-that)[ RSS](/packages/antoksa-callable-that-proxy/feed)WikiDiscussions main Synced 1mo ago

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

Callable "that" Proxy
=====================

[](#callable-that-proxy)

"That" Philosophy
-----------------

[](#that-philosophy)

Lightweight proxy "that" provides ability to create a callable for an object during runtime.

The idea of "that" is to reference the way how you usually create a callable for particular object.

```
$this->method(...) # For particular object

that()->method(...) # For an expected object which is about to be accessed during the loop
```

Concept
-------

[](#concept)

How often did you need to perform `array_map()` like this?

```
array_map(
    static function (MyClass $object): string {
        return $object->method();
    },
    $objects,
);

array_map(
    static fn (MyClass $object): string => $object->method(),
    $objects,
);

array_map(
    static fn (MyClass $object): string => $object->method($arg1, $arg2),
    $objects,
);

array_map(
    static fn (MyClass $object): string => $object->property,
    $objects,
);
```

Unfortunately, even though we can create objects like `[$this, 'method']`, but we can't access the object during iteration for runtime (e.g. `array_map()`, `array_filter()` etc.)

Lightweight proxy "that" brings this handy feature:

```
array_map(
    that()->method(...), # static fn (MyClass $object): string => $object->method()
    $objects,
);

array_map(
    that()->withArgs($arg1, $arg2)->method(...), # static fn (MyClass $object): string => $object->method($arg1, $arg2),
    $objects,
);

array_map(
    that()->property, # static fn (MyClass $object): string => $object->property
    $objects,
);
```

Usage
-----

[](#usage)

### Basic

[](#basic)

```
### Call method
[that(), 'method']
that()->method(...)
that()->call('method')
that(method: 'method')

### Add arguments
[that()->withArgs($arg1, $arg2), 'method']
that()->withArgs($arg1, $arg2)->method(...)
that()->call('method', [$arg1, $arg2])
[that(args: [$arg1, $arg2]), 'method']
that(args: [$arg1, $arg2])->method(...)

### Get Property
that()->property
that()->get('property')
that(property: 'property')
```

### Laravel Collection Advantage

[](#laravel-collection-advantage)

Yes, Laravel got `HighOrderedProxy` which allows to the chain of operations conveniently, but IDE loses the type for it:

```
collect($objects)
    ->map
    ->method() # Return type is lost
    ->filter
    ->anotherMethod($arg1)
    ->all();

collect($objects)
    ->map
    ->existingCollectionMethodWhichReturnsBool() # Even worse, now IDE thinks that it returns bool here
    ->filter # Static analysis tools complains
    ->anotherMethod($arg1)
    ->all();
```

That's why I personally for this case would prefer to avoid `HighOrderedProxy`. It`s where "that" proxy comes handy:

```
collect($objects)
    ->map([that()->method(...))
    ->filter(that()->withArgs($arg1)->anotherMethod(...))
    ->all(); # Return type never gets lost
```

### Note

[](#note)

First argument (class) **is not** required, however **when provided**, you take advantage of **IDE autocompletion**:

```
# Full support
that(MyClass::class)->method(...)
that()->setClass(MyClass::class)->method(...)
that(MyClass::class)->property
that()->setClass(MyClass::class)->property

# Partial support; IDE does not suggest method,
# but it`s clickable as soon as you type it
[that(MyClass::class), 'method']
[that()->setClass(MyClass::class), 'method']

# No support; However, eventually, you never need that unless
# you want to call method which exists in That class
that(MyClass::class)->call('method')
that(MyClass::class, method: 'method')
that(MyClass::class)->get('property')
that(MyClass::class, property: 'property')
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance43

Moderate activity, may be stable

Popularity2

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity45

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

Total

3

Last Release

459d ago

Major Versions

v1.0.0.x-dev → v2.0.02025-02-13

PHP version history (2 changes)v1.0.0PHP ^7.0

v2.0.0PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![Anton5360](https://avatars.githubusercontent.com/u/72033639?v=4)](https://github.com/Anton5360 "Anton5360 (27 commits)")

---

Tags

proxycallableruntimelightweightdynamicthatantoksa

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/antoksa-callable-that-proxy/health.svg)

```
[![Health](https://phpackages.com/badges/antoksa-callable-that-proxy/health.svg)](https://phpackages.com/packages/antoksa-callable-that-proxy)
```

###  Alternatives

[fideloper/proxy

Set trusted proxies for Laravel

7.3k174.4M559](/packages/fideloper-proxy)[ocramius/proxy-manager

A library providing utilities to generate, instantiate and generally operate with Object Proxies

5.0k82.4M230](/packages/ocramius-proxy-manager)[symfony/var-exporter

Provides tools to export, instantiate, hydrate, clone and lazy-load PHP objects

2.1k378.1M441](/packages/symfony-var-exporter)[friendsofphp/proxy-manager-lts

Adding support for a wider range of PHP versions to ocramius/proxy-manager

1.2k139.1M104](/packages/friendsofphp-proxy-manager-lts)[php-di/invoker

Generic and extensible callable invoker

26857.8M56](/packages/php-di-invoker)[zenstruck/callback

Callable wrapper to validate and inject arguments.

569.6M4](/packages/zenstruck-callback)

PHPackages © 2026

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