symbol = $symbol; } public function getChild(int $i, ?string $type = null) : ?Tree { return null; } public function getSymbol() : Token { return $this->symbol; } /** * @return ParseTree|null */ public function getParent() : ?Tree { return $this->parent; } public function setParent(RuleContext $parent) : void { $this->parent = $parent; } public function getPayload() : Token { return $this->symbol; } public function getSourceInterval() : Interval { if ($this->symbol === null) { return new Interval(-1, -2); } $tokenIndex = $this->symbol->getTokenIndex(); return new Interval($tokenIndex, $tokenIndex); } public function getChildCount() : int { return 0; } public function accept(ParseTreeVisitor $visitor) { return $visitor->visitTerminal($this); } public function getText() : ?string { return $this->symbol->getText(); } /** * @param array|null $ruleNames */ public function toStringTree(?array $ruleNames = null) : string { return (string) $this; } public function __toString() : string { if ($this->symbol->getType() === Token::EOF) { return ''; } return $this->symbol->getText() ?? ''; } }