PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-dev1
Elementor Website Builder – more than just a page builder v3.28.0-dev1
4.3.0-beta3 4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 All 452 releases
elementor / vendor_prefixed / twig / src / Node / Expression / GetAttrExpression.php

GetAttrExpression.php in Elementor Website Builder – more than just a page builder 3.28.0-dev1, at vendor_prefixed/twig/src/Node/Expression/GetAttrExpression.php

58 lines 2.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /*
4 * This file is part of Twig.
5 *
6 * (c) Fabien Potencier
7 * (c) Armin Ronacher
8 *
9 * For the full copyright and license information, please view the LICENSE
10 * file that was distributed with this source code.
11 */
12 namespace ElementorDeps\Twig\Node\Expression;
13
14 use ElementorDeps\Twig\Compiler;
15 use ElementorDeps\Twig\Extension\SandboxExtension;
16 use ElementorDeps\Twig\Template;
17 class GetAttrExpression extends AbstractExpression
18 {
19 public function __construct(AbstractExpression $node, AbstractExpression $attribute, ?AbstractExpression $arguments, string $type, int $lineno)
20 {
21 $nodes = ['node' => $node, 'attribute' => $attribute];
22 if (null !== $arguments) {
23 $nodes['arguments'] = $arguments;
24 }
25 parent::__construct($nodes, ['type' => $type, 'is_defined_test' => \false, 'ignore_strict_check' => \false, 'optimizable' => \true], $lineno);
26 }
27 public function compile(Compiler $compiler) : void
28 {
29 $env = $compiler->getEnvironment();
30 $arrayAccessSandbox = \false;
31 // optimize array calls
32 if ($this->getAttribute('optimizable') && (!$env->isStrictVariables() || $this->getAttribute('ignore_strict_check')) && !$this->getAttribute('is_defined_test') && Template::ARRAY_CALL === $this->getAttribute('type')) {
33 $var = '$' . $compiler->getVarName();
34 $compiler->raw('((' . $var . ' = ')->subcompile($this->getNode('node'))->raw(') && is_array(')->raw($var);
35 if (!$env->hasExtension(SandboxExtension::class)) {
36 $compiler->raw(') || ')->raw($var)->raw(' instanceof ArrayAccess ? (')->raw($var)->raw('[')->subcompile($this->getNode('attribute'))->raw('] ?? null) : null)');
37 return;
38 }
39 $arrayAccessSandbox = \true;
40 $compiler->raw(') || ')->raw($var)->raw(' instanceof ArrayAccess && in_array(')->raw('get_class(' . $var . ')')->raw(', CoreExtension::ARRAY_LIKE_CLASSES, true) ? (')->raw($var)->raw('[')->subcompile($this->getNode('attribute'))->raw('] ?? null) : ');
41 }
42 $compiler->raw('CoreExtension::getAttribute($this->env, $this->source, ');
43 if ($this->getAttribute('ignore_strict_check')) {
44 $this->getNode('node')->setAttribute('ignore_strict_check', \true);
45 }
46 $compiler->subcompile($this->getNode('node'))->raw(', ')->subcompile($this->getNode('attribute'));
47 if ($this->hasNode('arguments')) {
48 $compiler->raw(', ')->subcompile($this->getNode('arguments'));
49 } else {
50 $compiler->raw(', []');
51 }
52 $compiler->raw(', ')->repr($this->getAttribute('type'))->raw(', ')->repr($this->getAttribute('is_defined_test'))->raw(', ')->repr($this->getAttribute('ignore_strict_check'))->raw(', ')->repr($env->hasExtension(SandboxExtension::class))->raw(', ')->repr($this->getNode('node')->getTemplateLine())->raw(')');
53 if ($arrayAccessSandbox) {
54 $compiler->raw(')');
55 }
56 }
57 }
58