Closure Binding as an alternative to “use” variables
On his blog Mark Baker shares some thoughts on how to use closure binding to avoid having import variables with the use
keyword.
You’ll learn how to rewrite
$filteredArrayData = array_filter(
$arrayData,
function($value) use ($minimumPrice, $maximumPrice) {
return $value->price >= $minimumPrice && $value->price < $maximumPrice;
}
);
to
$filteredArrayData = array_filter(
$bookData,
$priceFilter->inRange(5.00, 15.00)
);
https://markbakeruk.net/2017/03/12/closure-binding-as-an-alternative-to-use-variables/
The post Closure Binding as an alternative to “use” variables appeared first on murze.be.