public function getVariable() : Variable
{
// Get the name of the variable
$variable_name = $this->getVariableName();
if (empty($variable_name)) {
throw new NodeException($this->node, "Variable name not found");
}
// Check to see if the variable exists in this scope
if (!$this->context->getScope()->hasVariableWithName($variable_name)) {
throw new IssueException(Issue::fromType(Issue::UndeclaredVariable)($this->context->getFile(), $this->node->lineno ?? 0, [$variable_name]));
}
return $this->context->getScope()->getVariableByName($variable_name);
}