<?php
namespace Tlf\Lexer2;
/**
* A value-object to represent an executable command during parsing.
*
* This is not used for execution.
*/
class Command implements \JsonSerializable {
/**
* The command's declaration w/ arguments, for debugging.
*/
public string $declaration;
/**
* The declared command (no arguments), for debugging
*/
public string $declared_command;
/**
* Array entry declarations, for debugging
*/
public ?array $array_entry_declarations;
/**
* The object this command will call
*/
public string $object;
/**
* The method on $object that this command will call
*/
public string $method;
/**
* Arguments to pass to $object->$method(...$args)
*/
public array $args = [];
public function toArray(): array {
return [
'--is_command--'=>true,
'object'=>$this->object,
'method'=>$this->method,
'args'=>$this->args
];
}
public function jsonSerialize(): mixed{
return $this->toArray();
}
}