PHPackages                             wyrfel/php-callback - 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. wyrfel/php-callback

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

wyrfel/php-callback
===================

A simple callable wrapper that allows better management of call parameters

v1.0.1(6y ago)06.4k[1 PRs](https://github.com/wyrfel/php-callback/pulls)MITPHPCI passing

Since Dec 20Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/wyrfel/php-callback)[ Packagist](https://packagist.org/packages/wyrfel/php-callback)[ RSS](/packages/wyrfel-php-callback/feed)WikiDiscussions master Synced 1mo ago

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

[![Build Status](https://camo.githubusercontent.com/fb826fe5e3a90544a0e518375bf6f2310657462737648056de1eeebf4b3cbbb7/68747470733a2f2f7472617669732d63692e6f72672f77797266656c2f7068702d63616c6c6261636b2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/wyrfel/php-callback)[![Maintainability](https://camo.githubusercontent.com/1dd032815053284ce209dec20823b36f7e1fdfd5a10bf67e2e1dec4197423f90/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f35346539383339653661336566666637636330372f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/wyrfel/php-callback/maintainability)[![Test Coverage](https://camo.githubusercontent.com/f246a5fe1c642fa0d2eb196a4de41ad03a7649d07ef5f1302a27223d55d30659/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f35346539383339653661336566666637636330372f746573745f636f766572616765)](https://codeclimate.com/github/wyrfel/php-callback/test_coverage)[![Latest Stable Version](https://camo.githubusercontent.com/7720b9479f1801d48763dab0bcbb53d053fbc4fdd4bda05cb5c77d52cab03219/68747470733a2f2f706f7365722e707567782e6f72672f77797266656c2f7068702d63616c6c6261636b2f76657273696f6e3f666f726d61743d666c6174)](https://packagist.org/packages/wyrfel/php-callback)[![Total Downloads](https://camo.githubusercontent.com/9f001886fdc34a79d4430a935be3b341f24e64aee57db32ccacedfa994c97c21/68747470733a2f2f706f7365722e707567782e6f72672f77797266656c2f7068702d63616c6c6261636b2f646f776e6c6f6164733f666f726d61743d666c6174)](https://packagist.org/packages/wyrfel/php-callback)[![License](https://camo.githubusercontent.com/19e74a133c3041a0afb674947e7077c7f129af247dd7f1af493e560701632c1f/68747470733a2f2f706f7365722e707567782e6f72672f77797266656c2f7068702d63616c6c6261636b2f6c6963656e73653f666f726d61743d666c6174)](https://packagist.org/packages/wyrfel/php-callback)

php-callback
============

[](#php-callback)

This is a simple callable helper that allows better control over the call parameters on the final call.

Concepts
--------

[](#concepts)

As opposed to an immediate function call, that accepts one set of parameters, when passing a callback, there are two occasions at which parameters may be passed - once at the time the callback is created/passed, the other at the time of the call.

We will call the former the **instantiation arguments** as they are passed at the time of the instantiation of the callback helper - and we'll call the latter the **invocation arguments** as they are passed at the time of invocation of the callback.

With a regular php callable, parameters can only be passed at the time of the call. An exception is the `array_walk` built-in that allows the specification of a userdata parameter when passing the callback that is then appended to the call parameters at the time of the call. This helper does the same thing, but with a few more capabilities.

When there are two sets of parameters, but the callable can of course only accept one set of parameters, the question arises how to merge the two sets into one. This helper is configurable to

- append the invocation arguments to the instantiation arguments `$callable(A1, A2, A3, B1, B2)`
- prepend the invocation arguments to the instantiation arguments `$callable(B1, B2, A1, A2, A3)`
- ignore the invocation arguments altogether `$callable(A1, A2, A3)`
- override the instantiation arguments with the invocation arguments based on position `$callable(B1, B2, A3)`

(with An begin the instantiation arguments an Bn being the invocation arguments)

Usage
-----

[](#usage)

```
$callback = new Callback([$this, 'methodName'], $withThis, $andThat);

$callback->appendInvocationArguments();
$callback->prependInvocationArguments();
$callback->ignoreInvocationArguments();
$callback->overrideInstantiationArguments();

preg_replace_callback($regexp, $callback, $subject);
```

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance53

Moderate activity, may be stable

Popularity23

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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

2

Last Release

2338d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/69ecbb50b3565cc040b7bb0431f1437f8b8358d906d4a23a71e47232dc3d49b3?d=identicon)[wyrfel](/maintainers/wyrfel)

---

Top Contributors

[![wyrfel](https://avatars.githubusercontent.com/u/425403?v=4)](https://github.com/wyrfel "wyrfel (2 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/wyrfel-php-callback/health.svg)

```
[![Health](https://phpackages.com/badges/wyrfel-php-callback/health.svg)](https://phpackages.com/packages/wyrfel-php-callback)
```

###  Alternatives

[ircmaxell/php-math-parser

A simple shunting-yard based math parser and executor for PHP

2916.7k](/packages/ircmaxell-php-math-parser)[bmcclure/cakephp-media-plugin

CakePHP Media Plugin

591.4k](/packages/bmcclure-cakephp-media-plugin)

PHPackages © 2026

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