use keyword isn't supported
PHP 5.3 introduced the 'use' keyword for lambda functions. WebIDE 387 doesn't recognize it
Example code
class Cart {
const PRICE_BUTTER = 1.00;
const PRICE_MILK = 3.00;
const PRICE_EGGS = 6.95;
protected $products = array();
public function add($product, $quantity)
{
$this->products[$product] = $quantity;
}
public function getQuantity($product)
{
return isset($this->products[$product]) ? $this->products[$product] : FALSE;
}
public function getTotal($tax)
{
$total = 0.00;
$callback =
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);;
}
}
Please sign in to leave a comment.
http://jetbrains.net/tracker/issue/WI-227
BTW, thanks for feedback on 5.3 features. Support for these features was added right before EAP and seems like we overlooked some parts of spec. All of these will receive high priority.
multiple use statements are also not working
example code
Thanks, that one is now addressed too.