getContent(); } public function setTargetUrl($url) { if ('' === ($url ?? '')) { throw new \InvalidArgumentException('无法跳转到空页面'); } $this->targetUrl = $url; $this->setContent( sprintf(' 正在跳转支付 %1$s ', htmlspecialchars($url, \ENT_QUOTES, 'UTF-8'))); $this->headers->set('Location', $url); return $this; } #[\ReturnTypeWillChange] public function jsonSerialize() { return $this->getContent(); } // 使用 PHP 8 兼容的新序列化方式 public function __serialize(): array { return ['content' => $this->content]; } public function __unserialize(array $data): void { $this->content = $data['content'] ?? ''; } }