$this->code; } /** * 节点类名(不含命名空间) */ public string $class { get => $this->class; } /** * 是否启用 */ public bool $enabled { get => $this->enabled; set => $this->enabled = $value; } /** * 扩展字段(用于原始/自定义字段透传) */ public array $expand { get => $this->expand; } /** * @var array 需要上一个节点 */ public array $required = []; public function __construct( string $code, string $class, bool $enabled = true, array $required = [], array $expand = [] ) { $this->code = $code; $this->class = $class; $this->enabled = $enabled; $this->required = $required; $this->expand = $expand; } public function toArray(): array { return array_merge([ 'code' => $this->code, 'class' => $this->class, 'enabled' => $this->enabled, 'required' => $this->required, ], $this->expand); } }