1<?php 2 3/* 4 * This file is part of Twig. 5 * 6 * (c) Fabien Potencier 7 * 8 * For the full copyright and license information, please view the LICENSE 9 * file that was distributed with this source code. 10 */ 11 12namespace Twig\Node; 13 14use Twig\Compiler; 15 16/** 17 * @internal 18 */ 19class SetTempNode extends Node 20{ 21 public function __construct($name, $lineno) 22 { 23 parent::__construct([], ['name' => $name], $lineno); 24 } 25 26 public function compile(Compiler $compiler) 27 { 28 $name = $this->getAttribute('name'); 29 $compiler 30 ->addDebugInfo($this) 31 ->write('if (isset($context[') 32 ->string($name) 33 ->raw('])) { $_') 34 ->raw($name) 35 ->raw('_ = $context[') 36 ->repr($name) 37 ->raw(']; } else { $_') 38 ->raw($name) 39 ->raw("_ = null; }\n") 40 ; 41 } 42} 43 44class_alias('Twig\Node\SetTempNode', 'Twig_Node_SetTemp'); 45