public function visitConst(Node $node) : Context
{
try {
$nameNode = $node->children['name'];
// Based on UnionTypeVisitor::visitConst
if ($nameNode->kind == \ast\AST_NAME) {
if (defined($nameNode->children['name'])) {
// Do nothing, this is an internal type such as `true` or `\ast\AST_NAME`
} else {
$constant = (new ContextNode($this->code_base, $this->context, $node))->getConst();
// Mark that this constant has been referenced from
// this context
$constant->addReference($this->context);
}
}
} catch (IssueException $exception) {
// We need to do this in order to check keys and (after the first 5) values in AST arrays.
// Other parts of the AST may also not be covered.
// (This issue may be a duplicate)
Issue::maybeEmitInstance($this->code_base, $this->context, $exception->getIssueInstance());
} catch (\Exception $exception) {
// Swallow any other types of exceptions. We'll log the errors
// elsewhere.
}
// Check to make sure we're doing something with the
// constant
$this->analyzeNoOp($node, Issue::NoopConstant);
return $this->context;
}