PHPackages                             czt08883/typed-callable - 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. czt08883/typed-callable

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

czt08883/typed-callable
=======================

0.5.1(11y ago)050UnlicensePHPPHP &gt;=5.4

Since Feb 13Pushed 11y ago1 watchersCompare

[ Source](https://github.com/czt08883/TypedCallable)[ Packagist](https://packagist.org/packages/czt08883/typed-callable)[ Docs](https://github.com/czt08883/TypedCallable)[ RSS](/packages/czt08883-typed-callable/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (4)Used By (0)

TypedCallable
=============

[](#typedcallable)

Abstract PHP class, which allows to implement callables with signature check

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

[](#installation)

```
composer require czt08883/typed-callable dev-master

```

Usage
=====

[](#usage)

Define your own class extending TypedCallable

```
use Czt08883\TypedCallable\TypedCallable\TypedCallable;

class OnDataCallable extends TypedCallable
{
    /**
     * Implement "useTemplate()" abstract method.
     * This method must return a callable, which will
     * be used as a template for signature check.
     *
     * @return callable
     */
    public function useTemplate()
    {
        return function(SomeClass $a, array $b, $c){};
    }
}

```

In your other class, which requires typed callable:

- store this typed callable as a property
- invoke this typed callable on some event, passing some data

    class DataReceiverExample {

    ```
    /**
     * @var OnDataCallable
     */
    private $onDataCallback;

    /**
     * Use this typed callable as an argument in some function
     * to setup a callback
     */
    public function setOnDataCallback(OnDataCallable $callback)
    {
        $this->onDataCallback = $callback;
    }

    /**
     * Execute your callback on some event, passing proper parameters.
     * For example, on receiving data from external source
     */
     public function onData()
     {
        // ... receive some data and pass it to callback ...
        call_user_func(
            $this->onDataCallback,
            [
                new SomeClass,
                ['some','data','as','array'],
                "some string"
            ]
        );
     }

    ```

    }

Use your DataReceiverExample

```
  $dataReceiver = new DataReceiverExample();
  $dataReceiver->setOnDataCallback(
      new OnDataCallable(
         function (SomeClass $a, array $b, $c) {
            // just display it, for example
            echo "Yay, received some data.";
         }
      )
  );

  /* Simulate incoming data event:
   * This will invoke a callback, installed earlier. So output will be
   *     "Yay, received some data."
   */
  $dataReceiver->onData();

```

Now let us test callback with wrong signature. Following code will trigger TypedCallableSignatureMismatchException with following message: "Callable signature mismatch. Callable must be: function(SomeClass $a, array $b, $c){...}"

```
   $dataReceiver->setOnDataCallback(
        new OnDataCallable(
           function (SomeOtherClass $c) {
             // ... other actions, not important here
           }
        )
    );

```

###  Health Score

23

—

LowBetter than 26% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Total

3

Last Release

4155d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3933937?v=4)[czt08883](/maintainers/czt08883)[@czt08883](https://github.com/czt08883)

---

Top Contributors

[![czt08883](https://avatars.githubusercontent.com/u/3933937?v=4)](https://github.com/czt08883 "czt08883 (1 commits)")

---

Tags

callablecallback

### Embed Badge

![Health badge](/badges/czt08883-typed-callable/health.svg)

```
[![Health](https://phpackages.com/badges/czt08883-typed-callable/health.svg)](https://phpackages.com/packages/czt08883-typed-callable)
```

###  Alternatives

[php-di/invoker

Generic and extensible callable invoker

26764.7M69](/packages/php-di-invoker)[winzou/state-machine

A very lightweight yet powerful PHP state machine

52414.0M19](/packages/winzou-state-machine)[zenstruck/callback

Callable wrapper to validate and inject arguments.

5610.3M6](/packages/zenstruck-callback)[phpfluent/callback

Allows you execute callbacks in a more dynamic way

1160.3k1](/packages/phpfluent-callback)[rybakit/arguments-resolver

ArgumentsResolver allows you to determine the arguments to pass to a function or method.

26112.9k7](/packages/rybakit-arguments-resolver)[raphhh/trex-reflection

Reflection helpers for callables and types

14345.1k11](/packages/raphhh-trex-reflection)

PHPackages © 2026

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