Phan\Parse\ParseVisitor::addConstant PHP Method

addConstant() private method

private addConstant ( ast\Node $node, string $name, ast\Node | mixed $value, integer $flags ) : void
$node ast\Node The node where the constant was found
$name string The name of the constant
$value ast\Node | mixed Either a node or a constant to be used as the value of the constant.
$flags integer Any flags on the definition of the constant
return void
    private function addConstant(Node $node, string $name, $value, int $flags = 0)
    {
        // Give it a fully-qualified name
        $fqsen = FullyQualifiedGlobalConstantName::fromStringInContext($name, $this->context);
        // Create the constant
        $constant = new GlobalConstant($this->context->withLineNumberStart($node->lineno ?? 0), $name, new UnionType(), $flags, $fqsen);
        $constant->setFutureUnionType(new FutureUnionType($this->code_base, $this->context, $value));
        $this->code_base->addGlobalConstant($constant);
    }