for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Remorhaz\Lexer\Runtime\IO;
use function array_merge;
/**
* @psalm-immutable
*/
final class Symbol implements SymbolInterface, LexemeInterface
{
* @var int
private $offset;
private $code;
* @var LexemeInterface
private $constituentLexeme;
public function __construct(int $offset, int $code, LexemeInterface $constituentLexeme)
$this->offset = $offset;
$this->code = $code;
$this->constituentLexeme = $constituentLexeme;
}
* @return int
* @psalm-pure
public function getOffset(): int
return $this->offset;
public function getCode(): int
return $this->code;
* @return LexemeInterface
public function getLexeme(): LexemeInterface
return $this;
* @return SymbolInterface[]
* @psalm-return array<int,SymbolInterface>
public function getSymbols(): array
return [$this];
* @spalm-pure
public function getConstituentLexeme(): LexemeInterface
return $this->constituentLexeme;
* @return int[]
* @psalm-return array<int,int>
public function getStartOffsets(): array
return array_merge([$this->offset], $this->constituentLexeme->getStartOffsets());
public function getFinishOffsets(): array
return array_merge([$this->offset], $this->constituentLexeme->getFinishOffsets());