Commit version 24.12.13800
This commit is contained in:
@ -10,23 +10,23 @@ use function strpos;
|
||||
final class Token
|
||||
{
|
||||
// Constants for token types
|
||||
const TOKEN_TYPE_WHITESPACE = 0;
|
||||
const TOKEN_TYPE_WORD = 1;
|
||||
const TOKEN_TYPE_QUOTE = 2;
|
||||
const TOKEN_TYPE_BACKTICK_QUOTE = 3;
|
||||
const TOKEN_TYPE_RESERVED = 4;
|
||||
const TOKEN_TYPE_RESERVED_TOPLEVEL = 5;
|
||||
const TOKEN_TYPE_RESERVED_NEWLINE = 6;
|
||||
const TOKEN_TYPE_BOUNDARY = 7;
|
||||
const TOKEN_TYPE_COMMENT = 8;
|
||||
const TOKEN_TYPE_BLOCK_COMMENT = 9;
|
||||
const TOKEN_TYPE_NUMBER = 10;
|
||||
const TOKEN_TYPE_ERROR = 11;
|
||||
const TOKEN_TYPE_VARIABLE = 12;
|
||||
public const TOKEN_TYPE_WHITESPACE = 0;
|
||||
public const TOKEN_TYPE_WORD = 1;
|
||||
public const TOKEN_TYPE_QUOTE = 2;
|
||||
public const TOKEN_TYPE_BACKTICK_QUOTE = 3;
|
||||
public const TOKEN_TYPE_RESERVED = 4;
|
||||
public const TOKEN_TYPE_RESERVED_TOPLEVEL = 5;
|
||||
public const TOKEN_TYPE_RESERVED_NEWLINE = 6;
|
||||
public const TOKEN_TYPE_BOUNDARY = 7;
|
||||
public const TOKEN_TYPE_COMMENT = 8;
|
||||
public const TOKEN_TYPE_BLOCK_COMMENT = 9;
|
||||
public const TOKEN_TYPE_NUMBER = 10;
|
||||
public const TOKEN_TYPE_ERROR = 11;
|
||||
public const TOKEN_TYPE_VARIABLE = 12;
|
||||
|
||||
// Constants for different components of a token
|
||||
const TOKEN_TYPE = 0;
|
||||
const TOKEN_VALUE = 1;
|
||||
public const TOKEN_TYPE = 0;
|
||||
public const TOKEN_VALUE = 1;
|
||||
|
||||
/** @var int */
|
||||
private $type;
|
||||
@ -40,29 +40,29 @@ final class Token
|
||||
$this->value = $value;
|
||||
}
|
||||
|
||||
public function value() : string
|
||||
public function value(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
|
||||
public function type() : int
|
||||
public function type(): int
|
||||
{
|
||||
return $this->type;
|
||||
}
|
||||
|
||||
public function isOfType(int ...$types) : bool
|
||||
public function isOfType(int ...$types): bool
|
||||
{
|
||||
return in_array($this->type, $types, true);
|
||||
}
|
||||
|
||||
public function hasExtraWhitespace() : bool
|
||||
public function hasExtraWhitespace(): bool
|
||||
{
|
||||
return strpos($this->value(), ' ')!== false ||
|
||||
return strpos($this->value(), ' ') !== false ||
|
||||
strpos($this->value(), "\n") !== false ||
|
||||
strpos($this->value(), "\t") !== false;
|
||||
}
|
||||
|
||||
public function withValue(string $value) : self
|
||||
public function withValue(string $value): self
|
||||
{
|
||||
return new self($this->type(), $value);
|
||||
}
|
||||
|
Reference in New Issue
Block a user