innmind / stack
Helper to build stacks
Installs: 1 537
Dependents: 4
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
pkg:composer/innmind/stack
Requires
- php: ~7.2|~8.0
Requires (Dev)
- phpunit/phpunit: ~8.0
- vimeo/psalm: ~4.4
This package is auto-updated.
Last update: 2025-08-28 06:02:21 UTC
README
Simple function to stack elements on top of each others. Useful to create object stacks.
Installation
composer require innmind/stack
Usage
use function Innmind\Stack\stack; $decorate = stack( static function(RequestHandler $handler) { return new ValidateRequest($handler); }, static function(RequestHandler $handler) { return new Security($handler); } ); $handler = $decorate(new MyRequestHandler);
The above example is equivalent to:
$handler = new ValidateRequest( new Security( new MyRequestHandler ) );
Note: the classes uses do not exist, they're only meant as an example.