sminnee/callbacklist
PHP class that manages a list of callbacks
Maintainers
0.1.1
2020-12-06 22:00 UTC
Requires
- php: ^7.1 || ^8
Requires (Dev)
- php-parallel-lint/php-console-highlighter: ^0.5.0
- php-parallel-lint/php-parallel-lint: ^1.2
- phpstan/phpstan-strict-rules: ^0.12.5
- phpunit/phpunit: ^7 || ^8 || ^9
- slevomat/coding-standard: ^6.4
- squizlabs/php_codesniffer: ^3.5
Suggests
None
Provides
None
Conflicts
None
Replaces
None
MIT 8c9f0a3a9f57aaa8cadb72eb579f5550a73abbc4
- Sam Minnee <sam.woop@silverstripe.com>
This package is auto-updated.
Last update: 2026-05-29 01:50:51 UTC
README
👁 Build Status
👁 Scrutinizer Code Quality
👁 codecov.io
👁 Latest Stable Version
👁 License
👁 Monthly Downloads
👁 GitHub Code Size
👁 GitHub Last Commit
👁 GitHub Activity
👁 GitHub Issues
This micropackage provides a simple class for managing a list of callbacks.
Usage
> composer require sminnee/callbacklist
use Sminnee\CallbackList\CallbackList; $list = new CallbackList; $list->add(function() { "this will get called"; }); $list->add(function() { "so will this"; }); $list->call(); // Or you can use it as a callable if you prefer $list();
Arguments can be passed:
$list->add(function($greeting) { "$greeting, world!"; }); $list("Hello");
Return values are collated as an array
use Sminnee\CallbackList\CallbackList; $list = new CallbackList; $list->add(function() { return "this will get returned"; }); $list->add(function() { return "so will this"; }); // ["this will get returned", "so will this"] var_dump($list());
Existing callbacks can be manipulated:
// Clear the list $list->clear(); // Or add a callback with a name $list->add(function($greeting) { "$greeting, world!"; }, 'greeter'); // And then remove by that name $list->remove('greeter');
And you can inspect the content of the list:
// Return a single named callback $list->get('greeter'); // Return everything as an array $list->getAll();
