I often pass local variables to functions declared in variables like:
public function getTotal($tax)
{
$total = 0.00;
$callback =
/* This line here: */
function ($quantity, $product) use ($tax, &$total)
{
$pricePerItem = constant(__CLASS__ . "::PRICE_" .
strtoupper($product));
$total += ($pricePerItem * $quantity) * ($tax + 1.0);
};
array_walk($this->products, $callback);
return round($total, 2);
}
Is it possible to pass every local variable that is declared in the same scope as declared function without listing them all like use($a,$b,$c ...)?
So if I would like like use(*) everything that was accessable in parent scope will be passed to declared function scope?
protectedor evenprivate.