From 8a6c578765535e2de39ffcf1f868aae407c5da2a Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 09:36:19 +0800 Subject: [PATCH 1/6] refactor: migrate to Hyperf\Contract\Htmlable interface This change consolidates the Htmlable contract usage by migrating from the local FriendsOfHyperf\Support\Contract\Htmlable to the upstream Hyperf\Contract\Htmlable interface. This reduces code duplication and aligns with Hyperf's core contracts. Changes: - Update FriendsOfHyperf\Support\Contract\Htmlable to extend Hyperf\Contract\Htmlable - Remove duplicate toHtml() method definition - Update imports in MailMessage and SimpleMessage to use Hyperf\Contract\Htmlable - Simplify type hints by removing redundant union types - Update HtmlString to implement Hyperf\Contract\Htmlable directly --- src/notification-mail/src/Message/MailMessage.php | 4 ++-- src/notification-mail/src/Message/SimpleMessage.php | 6 +++--- src/support/src/Contract/Htmlable.php | 6 +----- src/support/src/HtmlString.php | 5 ++--- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/notification-mail/src/Message/MailMessage.php b/src/notification-mail/src/Message/MailMessage.php index 67eba7778..4fad1d554 100644 --- a/src/notification-mail/src/Message/MailMessage.php +++ b/src/notification-mail/src/Message/MailMessage.php @@ -15,10 +15,10 @@ use FriendsOfHyperf\Mail\Contract\Attachable; use FriendsOfHyperf\Mail\Contract\Mailer; use FriendsOfHyperf\Mail\Markdown; -use FriendsOfHyperf\Support\Contract\Htmlable; use Hyperf\Conditionable\Conditionable; use Hyperf\Context\ApplicationContext; use Hyperf\Contract\Arrayable; +use Hyperf\Contract\Htmlable; use Hyperf\ViewEngine\Contract\Renderable; use function Hyperf\Collection\collect; @@ -294,7 +294,7 @@ public function data(): array /** * Render the mail notification message into an HTML string. */ - public function render(): Htmlable|\Hyperf\ViewEngine\Contract\Htmlable + public function render(): Htmlable { $container = ApplicationContext::getContainer(); if (isset($this->view)) { diff --git a/src/notification-mail/src/Message/SimpleMessage.php b/src/notification-mail/src/Message/SimpleMessage.php index ffaa1b3f5..19fe99de2 100644 --- a/src/notification-mail/src/Message/SimpleMessage.php +++ b/src/notification-mail/src/Message/SimpleMessage.php @@ -12,7 +12,7 @@ namespace FriendsOfHyperf\Notification\Mail\Message; use FriendsOfHyperf\Notification\Mail\Action; -use FriendsOfHyperf\Support\Contract\Htmlable; +use Hyperf\Contract\Htmlable; class SimpleMessage { @@ -223,9 +223,9 @@ public function toArray(): array /** * Format the given line of text. */ - protected function formatLine(Htmlable|\Hyperf\ViewEngine\Contract\Htmlable|array|string $line): \Hyperf\ViewEngine\Contract\Htmlable|Htmlable|string + protected function formatLine(Htmlable|array|string $line): Htmlable|string { - if ($line instanceof Htmlable || $line instanceof \Hyperf\ViewEngine\Contract\Htmlable) { + if ($line instanceof Htmlable) { return $line; } diff --git a/src/support/src/Contract/Htmlable.php b/src/support/src/Contract/Htmlable.php index 78affe369..ebab5d4a4 100644 --- a/src/support/src/Contract/Htmlable.php +++ b/src/support/src/Contract/Htmlable.php @@ -11,10 +11,6 @@ namespace FriendsOfHyperf\Support\Contract; -interface Htmlable +interface Htmlable extends \Hyperf\Contract\Htmlable { - /** - * Get content as a string of HTML. - */ - public function toHtml(): string; } diff --git a/src/support/src/HtmlString.php b/src/support/src/HtmlString.php index a1796d0ea..c3b30c238 100644 --- a/src/support/src/HtmlString.php +++ b/src/support/src/HtmlString.php @@ -11,10 +11,9 @@ namespace FriendsOfHyperf\Support; -use FriendsOfHyperf\Support\Contract\Htmlable; -use Stringable; +use Hyperf\Contract\Htmlable; -class HtmlString implements Htmlable, Stringable +class HtmlString implements Htmlable { /** * Create a new HTML string instance. From da081f31ab93a096e780121ac99d3557530a751f Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 10:39:47 +0800 Subject: [PATCH 2/6] refactor: rename getQueueName method to getPoolName for clarity --- types/Support/Support.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/Support/Support.php b/types/Support/Support.php index 1242871e4..db30c9e94 100644 --- a/types/Support/Support.php +++ b/types/Support/Support.php @@ -77,7 +77,7 @@ public function setMaxAttempts(int $maxAttempts): static return $this; } - public function getQueueName(): string + public function getPoolName(): string { return uniqid(); } From 218da5051694873ce47624765af2d33a698be380 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 10:45:17 +0800 Subject: [PATCH 3/6] refactor: ensure Htmlable interface is only defined if not already present --- src/support/src/Contract/Htmlable.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/support/src/Contract/Htmlable.php b/src/support/src/Contract/Htmlable.php index ebab5d4a4..829a9064d 100644 --- a/src/support/src/Contract/Htmlable.php +++ b/src/support/src/Contract/Htmlable.php @@ -11,6 +11,13 @@ namespace FriendsOfHyperf\Support\Contract; -interface Htmlable extends \Hyperf\Contract\Htmlable -{ +class_alias(\Hyperf\Contract\Htmlable::class, Htmlable::class); + +if (! interface_exists(Htmlable::class)) { + /** + * Interface Htmlable. + */ + interface Htmlable extends \Hyperf\Contract\Htmlable + { + } } From 3ad39d81a5c059705b8f8ef60f84038be8c316e5 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 10:46:02 +0800 Subject: [PATCH 4/6] refactor: add deprecation notice to Htmlable interface --- src/support/src/Contract/Htmlable.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/support/src/Contract/Htmlable.php b/src/support/src/Contract/Htmlable.php index 829a9064d..fb6ff7adc 100644 --- a/src/support/src/Contract/Htmlable.php +++ b/src/support/src/Contract/Htmlable.php @@ -16,6 +16,7 @@ class_alias(\Hyperf\Contract\Htmlable::class, Htmlable::class); if (! interface_exists(Htmlable::class)) { /** * Interface Htmlable. + * @deprecated since v3.1, will be removed in v3.2, use `\Hyperf\Contract\Htmlable` instead */ interface Htmlable extends \Hyperf\Contract\Htmlable { From 82d330b738bc0b60613908f255e9062a9dba187d Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 10:47:21 +0800 Subject: [PATCH 5/6] refactor: update deprecation notice for Htmlable interface to reflect version changes --- src/support/src/Contract/Htmlable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/support/src/Contract/Htmlable.php b/src/support/src/Contract/Htmlable.php index fb6ff7adc..13c503685 100644 --- a/src/support/src/Contract/Htmlable.php +++ b/src/support/src/Contract/Htmlable.php @@ -16,7 +16,7 @@ class_alias(\Hyperf\Contract\Htmlable::class, Htmlable::class); if (! interface_exists(Htmlable::class)) { /** * Interface Htmlable. - * @deprecated since v3.1, will be removed in v3.2, use `\Hyperf\Contract\Htmlable` instead + * @deprecated since v3.2.0, will be removed in v3.2.1, use `\Hyperf\Contract\Htmlable` instead */ interface Htmlable extends \Hyperf\Contract\Htmlable { From 4b52dfab75cfddfb12e44c747826acd2e03996e0 Mon Sep 17 00:00:00 2001 From: Deeka Wong <8337659+huangdijia@users.noreply.github.com> Date: Sat, 15 Nov 2025 10:50:30 +0800 Subject: [PATCH 6/6] refactor: update deprecation notice for Htmlable interface to clarify removal version --- src/support/src/Contract/Htmlable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/support/src/Contract/Htmlable.php b/src/support/src/Contract/Htmlable.php index 13c503685..080acb25d 100644 --- a/src/support/src/Contract/Htmlable.php +++ b/src/support/src/Contract/Htmlable.php @@ -16,7 +16,7 @@ class_alias(\Hyperf\Contract\Htmlable::class, Htmlable::class); if (! interface_exists(Htmlable::class)) { /** * Interface Htmlable. - * @deprecated since v3.2.0, will be removed in v3.2.1, use `\Hyperf\Contract\Htmlable` instead + * @deprecated since v3.2, will be removed in next major version, use `\Hyperf\Contract\Htmlable` instead */ interface Htmlable extends \Hyperf\Contract\Htmlable {