function TwigNodeVisitorCheckDeprecations::enterNode
File
- 
              core/lib/ Drupal/ Core/ Template/ TwigNodeVisitorCheckDeprecations.php, line 36 
Class
- TwigNodeVisitorCheckDeprecations
- Provides a Node Visitor to trigger errors if deprecated variables are used.
Namespace
Drupal\Core\TemplateCode
public function enterNode(Node $node, Environment $env) : Node {
  if ($node instanceof ModuleNode) {
    $this->usedNames = [];
    $this->assignedNames = [];
  }
  elseif ($node instanceof AssignNameExpression) {
    // Setting a variable makes subsequent usage is safe.
    $this->assignedNames[$node->getAttribute('name')] = $node->getAttribute('name');
  }
  elseif ($node instanceof NameExpression) {
    // Track each usage of a variable, unless set within the template.
    $name = $node->getAttribute('name');
    if (!in_array($name, $this->assignedNames)) {
      $this->usedNames[$name] = $name;
    }
  }
  return $node;
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
