__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ V / | |__) | __ ___ ____ _| |_ ___ | (___ | |__ ___| | | | |\/| | '__|> < | ___/ '__| \ \ / / _` | __/ _ \ \___ \| '_ \ / _ \ | | | | | | |_ / . \ | | | | | |\ V / (_| | || __/ ____) | | | | __/ | | |_| |_|_(_)_/ \_\ |_| |_| |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1 if you need WebShell for Seo everyday contact me on Telegram Telegram Address : @jackleetFor_More_Tools:
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\ExpressionLanguage\Node;
use Symfony\Component\ExpressionLanguage\Compiler;
/**
* @author Fabien Potencier <fabien@symfony.com>
*
* @internal
*/
class ArrayNode extends Node
{
protected int $index;
public function __construct()
{
$this->index = -1;
}
public function addElement(Node $value, ?Node $key = null): void
{
$key ??= new ConstantNode(++$this->index);
array_push($this->nodes, $key, $value);
}
/**
* Compiles the node to PHP.
*/
public function compile(Compiler $compiler): void
{
$compiler->raw('[');
$this->compileArguments($compiler);
$compiler->raw(']');
}
public function evaluate(array $functions, array $values): array
{
$result = [];
foreach ($this->getKeyValuePairs() as $pair) {
$result[$pair['key']->evaluate($functions, $values)] = $pair['value']->evaluate($functions, $values);
}
return $result;
}
public function toArray(): array
{
$value = [];
foreach ($this->getKeyValuePairs() as $pair) {
$value[$pair['key']->attributes['value']] = $pair['value'];
}
$array = [];
if ($this->isHash($value)) {
foreach ($value as $k => $v) {
$array[] = ', ';
$array[] = new ConstantNode($k);
$array[] = ': ';
$array[] = $v;
}
$array[0] = '{';
$array[] = '}';
} else {
foreach ($value as $v) {
$array[] = ', ';
$array[] = $v;
}
$array[0] = '[';
$array[] = ']';
}
return $array;
}
protected function getKeyValuePairs(): array
{
$pairs = [];
foreach (array_chunk($this->nodes, 2) as $pair) {
$pairs[] = ['key' => $pair[0], 'value' => $pair[1]];
}
return $pairs;
}
protected function compileArguments(Compiler $compiler, bool $withKeys = true): void
{
$first = true;
foreach ($this->getKeyValuePairs() as $pair) {
if (!$first) {
$compiler->raw(', ');
}
$first = false;
if ($withKeys) {
$compiler
->compile($pair['key'])
->raw(' => ')
;
}
$compiler->compile($pair['value']);
}
}
}
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| ArgumentsNode.php | File | 832 B | 0644 |
|
| ArrayNode.php | File | 2.7 KB | 0644 |
|
| BinaryNode.php | File | 6.27 KB | 0644 |
|
| ConditionalNode.php | File | 1.41 KB | 0644 |
|
| ConstantNode.php | File | 2.09 KB | 0644 |
|
| FunctionNode.php | File | 1.64 KB | 0644 |
|
| GetAttrNode.php | File | 6.03 KB | 0644 |
|
| NameNode.php | File | 942 B | 0644 |
|
| Node.php | File | 2.88 KB | 0644 |
|
| NullCoalesceNode.php | File | 1.65 KB | 0644 |
|
| UnaryNode.php | File | 1.43 KB | 0644 |
|