public function visitAssign(Node $node) : Context
{
// Get the type of the right side of the
// assignment
$right_type = UnionType::fromNode($this->context, $this->code_base, $node->children['expr']);
assert($node->children['var'] instanceof Node, "Expected left side of assignment to be a var");
if ($right_type->isType(VoidType::instance())) {
$this->emitIssue(Issue::TypeVoidAssignment, $node->lineno ?? 0);
}
// Handle the assignment based on the type of the
// right side of the equation and the kind of item
// on the left
$context = (new AssignmentVisitor($this->code_base, $this->context, $node, $right_type))($node->children['var']);
// Analyze the assignment for compatibility with some
// breaking changes betweeen PHP5 and PHP7.
(new ContextNode($this->code_base, $this->context, $node->children['var']))->analyzeBackwardCompatibility();
(new ContextNode($this->code_base, $this->context, $node->children['expr']))->analyzeBackwardCompatibility();
if ($node->children['expr'] instanceof Node && $node->children['expr']->kind == \ast\AST_CLOSURE) {
$closure_node = $node->children['expr'];
$method = (new ContextNode($this->code_base, $this->context->withLineNumberStart($closure_node->lineno ?? 0), $closure_node))->getClosure();
$method->addReference($this->context);
}
return $context;
}