/** * @param Node $node * The node where the constant was found * * @param string $name * The name of the constant * * @param Node|mixed $value * Either a node or a constant to be used as the value of * the constant. * * @param int $flags * 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); }