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 / NameExpression.php

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

63 lines 2.7 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 class NameExpression extends AbstractExpression
16 {
17 private $specialVars = ['_self' => '$this->getTemplateName()', '_context' => '$context', '_charset' => '$this->env->getCharset()'];
18 public function __construct(string $name, int $lineno)
19 {
20 parent::__construct([], ['name' => $name, 'is_defined_test' => \false, 'ignore_strict_check' => \false, 'always_defined' => \false], $lineno);
21 }
22 public function compile(Compiler $compiler) : void
23 {
24 $name = $this->getAttribute('name');
25 $compiler->addDebugInfo($this);
26 if ($this->getAttribute('is_defined_test')) {
27 if (isset($this->specialVars[$name])) {
28 $compiler->repr(\true);
29 } elseif (\PHP_VERSION_ID >= 70400) {
30 $compiler->raw('array_key_exists(')->string($name)->raw(', $context)');
31 } else {
32 $compiler->raw('(isset($context[')->string($name)->raw(']) || array_key_exists(')->string($name)->raw(', $context))');
33 }
34 } elseif (isset($this->specialVars[$name])) {
35 $compiler->raw($this->specialVars[$name]);
36 } elseif ($this->getAttribute('always_defined')) {
37 $compiler->raw('$context[')->string($name)->raw(']');
38 } else {
39 if ($this->getAttribute('ignore_strict_check') || !$compiler->getEnvironment()->isStrictVariables()) {
40 $compiler->raw('($context[')->string($name)->raw('] ?? null)');
41 } else {
42 $compiler->raw('(isset($context[')->string($name)->raw(']) || array_key_exists(')->string($name)->raw(', $context) ? $context[')->string($name)->raw('] : (function () { throw new RuntimeError(\'Variable ')->string($name)->raw(' does not exist.\', ')->repr($this->lineno)->raw(', $this->source); })()')->raw(')');
43 }
44 }
45 }
46 /**
47 * @deprecated since Twig 3.11 (to be removed in 4.0)
48 */
49 public function isSpecial()
50 {
51 trigger_deprecation('twig/twig', '3.11', 'The "%s()" method is deprecated and will be removed in Twig 4.0.', __METHOD__);
52 return isset($this->specialVars[$this->getAttribute('name')]);
53 }
54 /**
55 * @deprecated since Twig 3.11 (to be removed in 4.0)
56 */
57 public function isSimple()
58 {
59 trigger_deprecation('twig/twig', '3.11', 'The "%s()" method is deprecated and will be removed in Twig 4.0.', __METHOD__);
60 return !$this->isSpecial() && !$this->getAttribute('is_defined_test');
61 }
62 }
63