type = $event[0]; $this->event = $event[1]; $this->data = $data; return; } else if ($event instanceof ScriptEnum) { $this->type = 'script'; $this->event = $event->value; } else if ($event instanceof SystemEnum) { $this->type = 'system'; $this->event = $event->value; } // data处理 if ($data instanceof BaseScript) { $this->data = $data->toArray(); } else { $this->data = (array)$data; } } public function toJson(): string { return json_encode([ 'type' => $this->type, 'event' => $this->event, 'data' => $this->data, ], JSON_UNESCAPED_UNICODE); } }