mirror of
https://github.com/phabelio/PHP-Parser.git
synced 2024-11-30 04:29:15 +01:00
Fixed array value evaluation with unpacked array
This commit is contained in:
parent
8da6d7ac62
commit
54f19a0a66
@ -2,6 +2,7 @@
|
||||
|
||||
namespace PhpParser;
|
||||
|
||||
use function array_merge;
|
||||
use PhpParser\Node\Expr;
|
||||
use PhpParser\Node\Scalar;
|
||||
|
||||
@ -150,6 +151,8 @@ class ConstExprEvaluator
|
||||
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);
|
||||
}
|
||||
|
@ -22,6 +22,9 @@ class ConstExprEvaluatorTest extends \PHPUnit\Framework\TestCase
|
||||
['"foo"', "foo"],
|
||||
['[0, 1]', [0, 1]],
|
||||
['["foo" => "bar"]', ["foo" => "bar"]],
|
||||
['[...["bar"]]', ["bar"]],
|
||||
['[...["foo" => "bar"]]', ["foo" => "bar"]],
|
||||
['["a", "b" => "b", ...["b" => "bb", "c"]]', ["a", "b" => "bb", "c"]],
|
||||
['NULL', null],
|
||||
['False', false],
|
||||
['true', true],
|
||||
|
Loading…
Reference in New Issue
Block a user