Download the PHP package mpyw/unclosure without Composer
On this page you can find all versions of the php package mpyw/unclosure. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Please rate this library. Is it a good library?
Informations about the package unclosure
Unclosure

Closure unwrapper especially suited for Laravel PDO.
Requirements
Package | Version | Mandatory |
---|---|---|
PHP | ^7.4 || ^8.0 |
✅ |
PHPStan | >=1.1 |
Installing
Examples
Call PDO::setAttribute()
after database connection has been established
Temporarily change PDO
attributes
API
Value::withCallback()
Call $callback($value, ...$args)
or wrap its call into Closure
.
- When you pass
$value
asClosure
:- Return wrapped
Closure
which returns$callback($value(), ...$args)
.
- Return wrapped
- When you pass
$value
as a raw value:- Return
$callback($value, ...$args)
.
- Return
Arguments and Return Value
Name | Type | Description |
---|---|---|
$value |
mixed (A) Closure |
First argument for $callback which is unwrappable |
$callback |
(B) callable | A callback which takes unwrapped $value as the first argument |
...$args |
mixed | Second, third, ... arguments for $callback |
<Return Value> | mixed (C) Closure |
Decorated Closure or an unwrapped value |
(A) $value
Name | Type | Description |
---|---|---|
...$initialArgs |
mixed | Arguments for unwrapping Closure |
<Return Value> | mixed | An unwrapped value |
(B) $callback
Name | Type | Description |
---|---|---|
$value |
mixed | An unwrapped value |
...$args |
mixed | Arguments from Value::withCallback() |
<Return Value> | mixed | A decorated unwrapped value |
(C) Return Value
Name | Type | Description |
---|---|---|
...$initialArgs |
mixed | Arguments for unwrapping $value |
<Return Value> | mixed | An unwrapped value which is propagated from $value(...$initialArgs) |
Value::withEffect()
Value::withEffectForEach()
Call $callback(...$args)
, watching new assignment on &$value
. You can conditionally unwrap $value
in your $callback
by yourself.
- When you pass
$value
asClosure
:- If
$value
has been unwrapped, configurations via$configurator
are applied. - If
$value
still remains asClosure
, all configurations are canceled.
- If
- When you pass
$value
as a raw value:- Configurations via
$conigurator
are immediately applied.
- Configurations via
Arguments and Return Value
Name | Type | Description |
---|---|---|
&$value |
mixed (A) Closure |
An argument for $configurator which is unwrappable |
$configurator |
(B) callable | A configurator callback which takes unwrapped $value as the first argument |
$callback |
(D) callable | Any callback function |
...$args |
mixed | Arguments for $callback |
<Return Value> | mixed | Return value from $callback(...$args) |
(A) &$value
Name | Type | Description |
---|---|---|
<Return Value> | mixed | An unwrapped value |
(B) $configurator
Name | Type | Description |
---|---|---|
mixed |
mixed | An unwrapped value |
<Return Value> | null (C) callable |
An optional disposer function corresponding to the configurator |
(C) $configurator
Return Value
Name | Type | Description |
---|---|---|
mixed |
mixed | An unwrapped value |
(D) $callback
Name | Type | Description |
---|---|---|
...$args |
mixed | Arguments from Value::withEffect() |
<Return Value> | mixed |
All versions of unclosure with dependencies
PHP Build Version
Package Version
Requires
php Version
^8.2
The package mpyw/unclosure contains the following files
Loading the files please wait ....