public function visitReturn(Node $node) : Context
{
if (Config::get()->backward_compatibility_checks) {
(new ContextNode($this->code_base, $this->context, $node))->analyzeBackwardCompatibility();
}
// Make sure we're actually returning from a method.
if (!$this->context->isInFunctionLikeScope()) {
return $this->context;
}
// Get the method/function/closure we're in
$method = $this->context->getFunctionLikeInScope($this->code_base);
assert(!empty($method), "We're supposed to be in either method or closure scope.");
// Mark the method as returning something
$method->setHasReturn(($node->children['expr'] ?? null) !== null);
return $this->context;
}