private $defaultStrategy = false;
private $safeVars =
[];
public function __construct() { $this->safeAnalysis =
new SafeAnalysisNodeVisitor();
} public function enterNode(Node
$node, Environment
$env): Node
{ if ($node instanceof ModuleNode
) { if ($env->
hasExtension(EscaperExtension::
class) &&
$defaultStrategy =
$env->
getExtension(EscaperExtension::
class)->
getDefaultStrategy($node->
getTemplateName())) { $this->defaultStrategy =
$defaultStrategy;
} $this->safeVars =
[];
$this->blocks =
[];
} elseif ($node instanceof AutoEscapeNode
) { $this->statusStack
[] =
$node->
getAttribute('value'
);
} elseif ($node instanceof BlockNode
) { $this->statusStack
[] =
isset($this->blocks
[$node->
getAttribute('name'
)]) ?
$this->blocks
[$node->
getAttribute('name'
)] :
$this->
needEscaping($env);
} elseif ($node instanceof ImportNode
) { $this->safeVars
[] =
$node->
getNode('var'
)->
getAttribute('name'
);
}