Download the PHP package jclaveau/php-deferred-callchain without Composer
On this page you can find all versions of the php package jclaveau/php-deferred-callchain. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package php-deferred-callchain
PHP Deferred Callchain
This class simply provides a way to define fluent chain of methods, functions, array access calls before having the target (object or native value) you wan't to apply it to. Once the expected targets are available, simply call the chain on them as if it was a function.
Quality
Overview
Installation
php-deferred-callchain is installable via Composer
composer require jclaveau/php-deferred-callchain
Testing
Tests are located here and runnable by calling
./phpunit
Usage
- Functionnal and chained construction
- Fluent call chain
- Working with arrays
- Working with native types and functions
- Specifying on which class, interface, type or instance, the chain is callable
- Calls provoking exceptions
- Static calls
- API Reference
Functionnal and chained construction
DeferredCallChain can be instanciated classically
Statically
Or functionnaly
Fluent call chain
Working with arrays
Working with native types and functions
The features above make calls to objects methods easy and async but when their result is not an object, the fluent syntax has to stop, and the async behavior also.
Based on Daniel S Deboer work https://github.com/danielsdeboer/pipe, support of chained function calls has been added.
Some functions do not use the subject of the fluent syntax as first argument. In this case, giving '$$' as the parameter you want to be replaced by the subject.
Specifying on which class, interface, type or instance, the chain is callable
You can force the target of your call chain to:
-
be an instance of a specific class
-
implement a specific interface
-
be of a specific native type
- be a specific instance given at construction
Calls provoking exceptions
As a call can be made far before it's effectivelly applied, exceptions need more debug information for a smooth workflow. To achieve that, a line is added to every exception message thrown during a DeferredCallChain execution, pointing to the buggy call and where it is coded.
For example, an exception having as message will print
Static calls
Static calls can be useful, especially for singletons. For some technical reasons explained here, the only way to support it is to call them as normal methods (e.g. with -> ) and look for it as a static method once we know it doesn't exist as a regular one.
All versions of php-deferred-callchain with dependencies
symfony/polyfill-php72 Version ^1.12
jclaveau/php-fluent-trait Version ^1.1
jclaveau/php-visibility-violator Version ^1.0