function ConstExprEvaluator::evaluateArray
1 call to ConstExprEvaluator::evaluateArray()
- ConstExprEvaluator::evaluate in vendor/
nikic/ php-parser/ lib/ PhpParser/ ConstExprEvaluator.php
File
-
vendor/
nikic/ php-parser/ lib/ PhpParser/ ConstExprEvaluator.php, line 151
Class
- ConstExprEvaluator
- Evaluates constant expressions.
Namespace
PhpParserCode
private function evaluateArray(Expr\Array_ $expr) : array {
$array = [];
foreach ($expr->items as $item) {
if (null !== $item->key) {
$array[$this->evaluate($item->key)] = $this->evaluate($item->value);
}
elseif ($item->unpack) {
$array = array_merge($array, $this->evaluate($item->value));
}
else {
$array[] = $this->evaluate($item->value);
}
}
return $array;
}